local lever = script.Parent
local detector = lever:WaitForChild("ClickDetector")
local WalkTo = script.Parent.Parent:WaitForChild("WalkTo")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
detector.MouseClick:Connect(function()
if WalkTo and humanoid then
humanoid.WalkToPoint = WalkTo.Position
humanoid:MoveTo(WalkTo.Position)
end
end)```
#Move player to designated part
28 messages · Page 1 of 1 (latest)
try gamePlayersPlayerAdded
if the local script is in workspace it won't run
Is it in the right place? Or should I put it somewhere else?
it will only run in starterplayerscripts startercharacterscripts or playergui
:/
** You are now Level 6! **
Ok I'll try
Ok the script works now but
I walk to the part after the animation is played
Should I just dalay the animation?
I think I've figured out the problem
pretty sure there's a movetoreached event or something like that you could use
depends
for this one it's mostly vibe so i would do character since it deals with character
Got it 👍
MoveToFinished()?
probably
:/
I'll just try until it works thanks
Ok I fixed it
ish
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local detector = game.Workspace.LeverCutscene.LeverRig.ClickDetector
local lever = game.Workspace.LeverCutscene.LeverRig
local leverAnimation = lever.AnimationController.Animator:LoadAnimation(game.ReplicatedStorage.Animations.UseLever_Lever)
local walkTo = lever.Parent:WaitForChild("WalkTo")
local cd = false
local humanoid = char:WaitForChild("Humanoid")
local playerAnimation = humanoid:LoadAnimation(game.ReplicatedStorage.Animations.UseLever_Player)
detector.MouseClick:Connect(function()
if cd == true then return end
cd = true
humanoid.WalkToPoint = walkTo.Position
humanoid:MoveTo(walkTo.Position)
humanoid.MoveToFinished():Wait()
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
leverAnimation:Play()
playerAnimation:Play()
game.ReplicatedStorage.Remotes.LeverCutscene:FireServer("UseLever")
--Return WalkSpeed and JumpPower when animation is done
task.delay(1.5, function()
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
end)
--Prevent players from spamming the lever
task.delay(5, function()
cd = false
end)
end)
I have problems with the
humanoid.MoveToFinished():Wait()
I got the error Workspace.merest_2.LeverClickHandler:21: attempt to call a RBXScriptSignal value