Hello, Im trying to work on a script for a horror game where an NPC hides if you shine a light on them.
The hiding animation wont work, Can someone help me?
local Light = game.Workspace.Views.ViewRight.SpotLight
local Model = script.Parent
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://00000000" -- hidden ID
if Light.Enabled == false then
wait(5)
Model:PivotTo(CFrame.new(-30.998, 8.786, -3.519))
end
if Light.Enabled == true then
wait(5)
Model:PivotTo(CFrame.new(-30.998, 8.786, -12.119))
Animation:Play()
end
local Light = game.Workspace.Views.ViewRight.SpotLight
local Model = script.Parent
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://00000000" -- hidden ID
if not Light.Enabled then
wait(5)
Model:PivotTo(CFrame.new(-30.998, 8.786, -3.519))
end
if Light.Enabled then
wait(5)
Model:PivotTo(CFrame.new(-30.998, 8.786, -12.119))
Model.Humanoid.Animator:LoadAnimation(Animation):Play()
end