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

How could I access the player's humanoid once they joined?

Asked by 6 years ago

I want to make it so that the player can't move or jump or move the camera (for a little cutscene) but I have no idea how. I attempted to do it myself, but I got an error.

local pName = game.Players:GetChildren().Name
local pModel = game.Workspace:GetChildren(pName)
print (pName)
pModel.Humanoid.JumpPower = 0
pModel.Humanoid.WalkSpeed = 0

Can anyone help with this?

0
You could maybe use ChildAdded()? WaddelsG 69 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago
Edited 6 years ago

You would use the PlayerAdded event to connect to a function that waits for their character to load. This would set their walkspeed and jumping to 0.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Wait()
    player.Character:WaitForChild("Humanoid")
    player.Character.Humanoid.WalkSpeed = 0
    player.Character.Humanoid.JumpPower = 0
end)

Another thing is that it when trying to find their character (the model in the workspace) , never find it in the workspace, as if there is something else with the same name, it may error. Every player has a property called "Character". Also, doing pName = game.Players:GetChildren().Name won't work, as GetChildren returns a table of the instance (players)'s table.

0
i'd suggesting binding CharacterAdded to a function too. that way if they reset it still works. RubenKan 3615 — 6y
Ad

Answer this question