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

How do i reference every players character?

Asked by 3 years ago
Edited 3 years 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 258 — 3y

1 answer

Log in to vote
0
Answered by 3 years 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 465 — 3y
Ad

Answer this question