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!!
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!!
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
12 comments
http://wiki.roblox.com/index.php?title=Controlling_a_Player%27s_Character
Thanks!
Um, it won't work?
Sorry, edited it. Made a typo
Still won't work... I'll try it in a game situation
OMG. THERE WERE TWO TYPOS ON THE SAME LINE. FINALLY FIXED SORRY LOL
Haha there we go. Why am I a floating camera 0-o
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
I think there's an error in the script
It's underlining the first "human" in blue
Sorry, I mispelt 'Humanoid'. TYPOS THESE DAYS
There we go :) Thank you!!