mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-15 21:51:55 +00:00
Actor support
This commit is contained in:
68
src/client/Character/Server/Flashlight.lua
Normal file
68
src/client/Character/Server/Flashlight.lua
Normal file
@@ -0,0 +1,68 @@
|
||||
local Flashlight = {}
|
||||
Flashlight.__index = Flashlight
|
||||
|
||||
local Remote = Instance.new("RemoteEvent") :: RemoteEvent
|
||||
Remote.Name = "Flashlight"
|
||||
Remote.Parent = _G.include(script, "CharacterShared")
|
||||
|
||||
function Flashlight.constructor(Head: BasePart)
|
||||
local FlashlightPart = Instance.new("Part") :: Part
|
||||
FlashlightPart.Size = Vector3.new(.1,.1,.1)
|
||||
FlashlightPart.CFrame = Head.CFrame+Vector3.yAxis
|
||||
FlashlightPart.CanCollide = false
|
||||
FlashlightPart.CastShadow = false
|
||||
FlashlightPart.Transparency = 1
|
||||
|
||||
local SpotLight = Instance.new("SpotLight") :: SpotLight
|
||||
SpotLight.Color = Color3.new(1,1,1)
|
||||
SpotLight.Angle = 80
|
||||
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
|
||||
|
||||
local ToggleSound = Instance.new("Sound") :: Sound
|
||||
ToggleSound.SoundId = "rbxassetid://16454678462"
|
||||
ToggleSound.Volume = .5
|
||||
ToggleSound.Parent = Head
|
||||
|
||||
return setmetatable({
|
||||
SpotLight = SpotLight,
|
||||
ToggleSound = ToggleSound,
|
||||
Remote = Remote
|
||||
}, Flashlight)
|
||||
end
|
||||
|
||||
local FlashlightEnabled = false
|
||||
|
||||
function Flashlight:On()
|
||||
FlashlightEnabled = true
|
||||
self.ToggleSound:Play()
|
||||
self.SpotLight.Enabled = FlashlightEnabled
|
||||
end
|
||||
|
||||
function Flashlight:Off()
|
||||
FlashlightEnabled = false
|
||||
self.ToggleSound:Play()
|
||||
self.SpotLight.Enabled = FlashlightEnabled
|
||||
end
|
||||
|
||||
function Flashlight:Toggle()
|
||||
-- FlashlightEnabled = not FlashlightEnabled
|
||||
if FlashlightEnabled then
|
||||
self:Off()
|
||||
else
|
||||
self:On()
|
||||
end
|
||||
end
|
||||
|
||||
return Flashlight
|
||||
Reference in New Issue
Block a user