mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-15 21:51:55 +00:00
Server actions, keybinds TCP, and flashlight UDP
This commit is contained in:
@@ -5,68 +5,66 @@
|
||||
local Flashlight = {}
|
||||
Flashlight.__index = Flashlight
|
||||
|
||||
local Remote = Instance.new("UnreliableRemoteEvent") :: UnreliableRemoteEvent
|
||||
Remote.Name = "Flashlight"
|
||||
Remote.Parent = _G.include(script, "CharacterShared")
|
||||
Flashlight.Enabled = false
|
||||
|
||||
function Flashlight.constructor(Head: BasePart)
|
||||
function Flashlight.constructor(HumanoidRootPart: BasePart)
|
||||
local FlashlightPart = Instance.new("Part") :: Part
|
||||
FlashlightPart.Size = Vector3.new(.1,.1,.1)
|
||||
FlashlightPart.CFrame = Head.CFrame+Vector3.yAxis
|
||||
FlashlightPart.CFrame = HumanoidRootPart.CFrame
|
||||
FlashlightPart.CanCollide = false
|
||||
FlashlightPart.CastShadow = false
|
||||
FlashlightPart.Anchored = true
|
||||
FlashlightPart.Transparency = 1
|
||||
|
||||
local SpotLight = Instance.new("SpotLight") :: SpotLight
|
||||
SpotLight.Color = Color3.new(1,1,1)
|
||||
SpotLight.Angle = 80
|
||||
SpotLight.Angle = 90
|
||||
SpotLight.Range = 30
|
||||
SpotLight.Brightness = 1
|
||||
SpotLight.Shadows = true
|
||||
SpotLight.Enabled = false
|
||||
SpotLight.Parent = FlashlightPart
|
||||
|
||||
local Weld = Instance.new("WeldConstraint") :: WeldConstraint
|
||||
Weld.Part0 = Head
|
||||
Weld.Part1 = FlashlightPart
|
||||
Weld.Parent = FlashlightPart
|
||||
|
||||
FlashlightPart.Anchored = false
|
||||
FlashlightPart.Parent = Head
|
||||
FlashlightPart.Parent = HumanoidRootPart
|
||||
|
||||
local ToggleSound = Instance.new("Sound") :: Sound
|
||||
ToggleSound.SoundId = "rbxassetid://16454678462"
|
||||
ToggleSound.Volume = .5
|
||||
ToggleSound.Parent = Head
|
||||
ToggleSound.Parent = HumanoidRootPart
|
||||
|
||||
return setmetatable({
|
||||
SpotLight = SpotLight,
|
||||
ToggleSound = ToggleSound,
|
||||
Remote = Remote
|
||||
FlashlightPart = FlashlightPart,
|
||||
SpotLight = SpotLight,
|
||||
ToggleSound = ToggleSound
|
||||
}, Flashlight)
|
||||
end
|
||||
|
||||
local FlashlightEnabled = false
|
||||
function Flashlight:On(CameraCFrame: CFrame)
|
||||
Flashlight.Enabled = true
|
||||
|
||||
function Flashlight:On()
|
||||
FlashlightEnabled = true
|
||||
self.ToggleSound:Play()
|
||||
self.SpotLight.Enabled = FlashlightEnabled
|
||||
(self.FlashlightPart :: Part).CFrame *= CameraCFrame;
|
||||
(self.ToggleSound :: Sound):Play();
|
||||
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
||||
end
|
||||
|
||||
function Flashlight:Off()
|
||||
FlashlightEnabled = false
|
||||
self.ToggleSound:Play()
|
||||
self.SpotLight.Enabled = FlashlightEnabled
|
||||
Flashlight.Enabled = false
|
||||
|
||||
(self.ToggleSound :: Sound):Play();
|
||||
(self.SpotLight :: SpotLight).Enabled = Flashlight.Enabled
|
||||
end
|
||||
|
||||
function Flashlight:Toggle()
|
||||
-- FlashlightEnabled = not FlashlightEnabled
|
||||
if FlashlightEnabled then
|
||||
function Flashlight:Toggle(CameraCFrame: CFrame?)
|
||||
if Flashlight.Enabled then
|
||||
self:Off()
|
||||
else
|
||||
self:On()
|
||||
self:On(CameraCFrame :: CFrame)
|
||||
end
|
||||
end
|
||||
|
||||
function Flashlight:SetCFrame(CameraCFrame: CFrame)
|
||||
|
||||
end
|
||||
|
||||
return Flashlight
|
||||
Reference in New Issue
Block a user