So I want to mention a player in a normal script... I can't use localplayer like I used until now cuz Im not using a local script, I would love help thx :)
✓ ANSWER ACCEPTED
How do I mention player on a normal script?
2 answers
✓ Accepted answer
local plr
game.Players.PlayerAdded:Connect(function(player)
plr = player
end)
wait(1) -- To wait for the player to add
print(plr.Name)
It sets another variable (plr) to the player that gets defined when the PlayerAdded function runs. If you need any further explanation just ask.
This is a way you can get a player from a server-side script if you have the players character.
local Players = game:GetService("Players")
local part = script.Parent
local function onTouched(part)
local player = Players:GetPlayerFromCharacter(part.Parent) --part.Parent refers to the Character.
print(player.Name .. " pressed me!")
end
part.Touched:Connect(onTouched)
I don't know what you mean by "mentioning a player". Like, in what context?
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
In what context do you want to mention a player and when? When a player clicks on a clickdetector? Or when a player walks on a part? There are different ways to approach based on context.
I think he just meant defining the local player. When you define it once, you can use it on other functions.
ah true.