Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do i reference every players character?

Asked by 3 days ago
Edited 3 days ago

I am trying to make a script that will unanchore every players humanoid rootpart on a NumberValue changed. The problem is I dont know how to refer to a players character.

0
Even though this is answered, please include the code you are working with next time. matiss112233 243 — 3d

1 answer

Log in to vote
0
Answered by 3 days ago

To get a players character

Client

Player, starter pack and player gui

game.Players.LocalPlayer:WaitForChild("Character")

Server

ServerScriptService and workspace

--When a player is added, works on client too but might not in workspace

game.Players.PlayerAdded:Connect(function(player)
    --Action
end)

--or, this uses touched event since there is no other way
local players = game:GetService("Players")
part.Touched:Connect(function(hit)
    local player =players:GetPlayerFromCharacter(hit.Parent)
end)
0
Yeah don't do game.Players.LocalPlayer:WaitForChild("Character"). That's going to infinite yield Character isn't a child of the Player it's a property. Anyway, just use StarterCharacterScripts and game.Players.LocalPlayer.Character. farrizbb 460 — 3d
Ad

Answer this question