Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
cboyce1 40
9 years ago

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

Log in to vote
1
Answered by 9 years ago

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)
0
Thanks! cboyce1 40 — 9y
0
Um, it won't work? cboyce1 40 — 9y
0
Sorry, edited it. Made a typo DigitalVeer 1473 — 9y
View all comments (8 more)
0
Still won't work... I'll try it in a game situation cboyce1 40 — 9y
0
OMG. THERE WERE TWO TYPOS ON THE SAME LINE. FINALLY FIXED SORRY LOL DigitalVeer 1473 — 9y
0
Haha there we go. Why am I a floating camera 0-o cboyce1 40 — 9y
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 DigitalVeer 1473 — 9y
0
I think there's an error in the script cboyce1 40 — 9y
0
It's underlining the first "human" in blue cboyce1 40 — 9y
0
Sorry, I mispelt 'Humanoid'. TYPOS THESE DAYS DigitalVeer 1473 — 9y
0
There we go :) Thank you!! cboyce1 40 — 9y
Ad

Answer this question