mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Light switch animation
This commit is contained in:
@@ -61,8 +61,8 @@ export type LanternsTree = {
|
||||
}
|
||||
|
||||
export type LightSwitchProperties = {
|
||||
Switch: Instance?,
|
||||
Lights: {Instance}?,
|
||||
Switch: BasePart?,
|
||||
Lights: {BasePart}?,
|
||||
Prompt: ProximityPrompt?,
|
||||
ClickSound: Sound?,
|
||||
ColorActivated: Color3?,
|
||||
|
||||
@@ -30,6 +30,7 @@ StarterPlayer_Stuff()
|
||||
Lighting_Stuff()
|
||||
Workspace_Stuff()
|
||||
|
||||
|
||||
--Map
|
||||
local Interactables = TagsConstructor:__Interactables()
|
||||
print("[DEBUG] Interactables=", Interactables)
|
||||
@@ -39,24 +40,40 @@ print("[DEBUG] Interactables=", Interactables)
|
||||
Guide for lights with toggable switches:
|
||||
TODO
|
||||
]]
|
||||
local TweenModule = require(Storage:WaitForChild("Tween"))
|
||||
local LightSwitchTween = TweenModule.constructor(TweenInfo.new(.1, Enum.EasingStyle.Linear))
|
||||
|
||||
for _, LightProperties in Interactables.LightSwitches do
|
||||
if LightProperties.Prompt and LightProperties.Switch then
|
||||
local Prompt = PromptsConstructor.constructor(LightProperties.Prompt, LightProperties.Switch)
|
||||
local Enabled = false
|
||||
local LightEnabled = false
|
||||
|
||||
if LightProperties.ColorDeactivated and LightProperties.ColorActivated and LightProperties.Prompt and LightProperties.Lights then
|
||||
Prompt:AddHookTriggered(function(_Player: Player)
|
||||
Enabled = not Enabled
|
||||
--*Light switch animation*
|
||||
LightEnabled = not LightEnabled
|
||||
|
||||
local Switch = LightProperties.Switch
|
||||
if Enabled then
|
||||
LightSwitchTween:Start(Switch, {
|
||||
CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),0)+Vector3.new(0,.15,0)
|
||||
})
|
||||
else
|
||||
LightSwitchTween:Start(Switch, {
|
||||
CFrame = CFrame.new(Switch.Position)*CFrame.Angles(0,math.rad(90),math.rad(70))-Vector3.new(0,.15,0)
|
||||
})
|
||||
end
|
||||
|
||||
if LightProperties.ClickSound then
|
||||
LightProperties.ClickSound:Play()
|
||||
end
|
||||
|
||||
for n: number = 1, #LightProperties.Lights do
|
||||
local LightObj = LightProperties.Lights[n]
|
||||
LightObj.PointLight.Enabled = Enabled
|
||||
|
||||
if Enabled then
|
||||
local Light = LightObj:FindFirstChildWhichIsA("PointLight", true) or LightObj:FindFirstChildWhichIsA("SpotLight", true)
|
||||
if Light then
|
||||
Light.Enabled = LightEnabled
|
||||
end
|
||||
if LightEnabled then
|
||||
LightObj.Color = LightProperties.ColorActivated
|
||||
LightObj.Material = Enum.Material.Neon
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user