Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I Stop a Player from moving their character?

This may be a little hard to explain, but what i'm trying to do is move a character's humanoid to a position, but the problem is as the script move em, they're still able to move their own character, which stops the script from moving the humanoid to a certain part. For an example "hum:MoveTo(pa)" that will walk them to that point, but if they walk a different direction by using the W,A,S,D keys then it will no longer move em to "pa", so how do I move a player to a part with the W,A,S,D keys disabled (as in they cannot move their character, but their speed is at 50)

wait(3)
local p = game.Players.LocalPlayer
local char = p.Character or p.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local pa = game.Workspace.lel.Position

while true do
wait()
hum.WalkSpeed = 16
print("moving...")
wait(0.1)
hum:MoveTo(pa)
hum.MoveToFinished:wait()
print("working")
end

It is possible, there are certain game that have this.

2 comments

1

.Torso.Anchored = true simplest method

0

@protectiveebob If the torso is anchored, wouldn't the player not be able to move at all? I'll try it later, at school right now, lol.

1 answer

✓ Accepted answer

First, set their walk speed to 0 in case they are moving.

After that, disable "ControlScript" in the player>PlayerScripts.

Then set the walk speed back to normal.

Example:

script.Parent.Touched:Connect(function(part)
local h = part.Parent:FindFirstChild('Humanoid')
if h then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
h.WalkSpeed = 0
player.PlayerScripts.ControlScript.Disabled = true
h.WalkSpeed = 16
end
end)

The script is untested, and is just an example, but you get it right?

2 comments

0

Did not fully answer my question, but It helped me in a way.

0

Nvm forget about ^ it fully helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.