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