#Move player to designated part

28 messages · Page 1 of 1 (latest)

gentle girder
#
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)```
magic geyser
#

try gamePlayersPlayerAdded

wheat cliff
#

if the local script is in workspace it won't run

gentle girder
#

Is it in the right place? Or should I put it somewhere else?

wheat cliff
#

it will only run in starterplayerscripts startercharacterscripts or playergui

gentle girder
#

:/

cloud mortarBOT
#

studio** You are now Level 6! **studio

gentle girder
#

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

wheat cliff
#

pretty sure there's a movetoreached event or something like that you could use

gentle girder
#

Ok

#

Btw

#

Should I put it in StarterCharacter or StarterPlayer

wheat cliff
#

depends

#

for this one it's mostly vibe so i would do character since it deals with character

gentle girder
#

Got it 👍

wheat cliff
#

probably

gentle girder
#

:/

#

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