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

How can I fix this script so a character won't move?

I need a character that spawns to not be able to move at all. How can I change this script to either work or be more efficient?

Thank you!!

1 answer

✓ Accepted answer

There are multiple steps you can take! The easiest way would to immediately anchor the players character upon spawning:

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
for _,v in pairs(c:GetChildren()) do
if v:IsA("BasePart") then v.Anchored = true end
end
end)
end)

If you want to take a more complex way, you can try using the ControllerService; Here's the wiki link to it:

http://wiki.roblox.com/index.php?title=Controlling_a_Player%27s_Character

Or even a more simple way:

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
local human = c.Humanoid or c:WaitForChild("Humanoid")
human.WalkSpeed = 0
end)
end)

12 comments

0

Thanks!

0

Um, it won't work?

0

Sorry, edited it. Made a typo

0

Still won't work... I'll try it in a game situation

0

OMG. THERE WERE TWO TYPOS ON THE SAME LINE. FINALLY FIXED SORRY LOL

0

Haha there we go. Why am I a floating camera 0-o

0

Because the character is anchored. That occurs when the character gets anchored. Hold up, you may like this new one even better. I'll edit my post

0

I think there's an error in the script

0

It's underlining the first "human" in blue

0

Sorry, I mispelt 'Humanoid'. TYPOS THESE DAYS

0

There we go :) Thank you!!

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