Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there any other way to define a player using a server script?

I know there is:

game.Players.PlayerAdded:Connect(function(plr)

but I need a command that would run every time (like when a player dies, etc) not just when the player joins. Is there anything else that can define a player like how in a local script:

game.Players.LocalPlayer

2 comments

0

No, and I don't think you should be trying this. Use a local script.

0

what command do you need specifically?

3 answers

No. Scripts cannot read your mind. The script doesnt know which player to pick. The script is like "uhh should i pick InfernoExecutioner or like that guest over there? dunno.". If scripts could read your mind, scripting would be much easier.

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character) -- fires everytime a player respawns
print(player.Name)
end)
end)

You can move the main script or whatever script your working with into StarterCharacter.

Now inside the script you can find the player like this:

game.Players:FindFirstChild(script.Parent.Name)

What that does is it finds the Parents name (Which is the players name) in Players

I hope this helped

This discussion is preserved as it was. New answers, comments, and votes are closed.