Auto-walk Issue

I really wanted to make a game with cut-scenes, but there is a problem holding me back from actually doing what I want to. I used the MoveTo function, but every time the player tried to escape, it just glitches.

robloxapp-20200604-1359494.wmv

local deb = false

script.Parent.Touched:Connect(function(hit)
	if deb == false then
	deb = true
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local currentwalkspeed = player.Character.Humanoid.WalkSpeed
		print(currentwalkspeed)
		while true do
			player.Character.Humanoid:MoveTo(game.Workspace.Part.Position)
			wait()
		end
	end
	deb = false
	end
end)
1 Like

When the player inputs a movement command, it cancel MoveTo(). You would need to disable the player’s ability to move. This can only be done on the client, as a WalkSpeed is still necessary. When the player touches the part, fire a remote to the client to temporarily disable their movement.
Something like this:

local controls = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule):GetControls()

RemoteEvent.onClientEvent:Connect(function(toggle)
        if toggle then
                controls:Enable()
        else
                controls:Disable()
        end
end)

Also, since you’re putting the MoveTo instead of a while true loop, the humanoid will be constantly trying to walk to that position. You can wait for the MoveTo to finish with

player.Character.Humanoid.MoveToFinished:Wait()
5 Likes