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

How do i find a LocalPlayer in a normal script?

Asked by 7 years ago
Edited 7 years ago

I need to way to find to localplayer and use it as a variable in a normal script that is in ServerScriptService :)

1 answer

Log in to vote
-1
Answered by 7 years ago

Yes there is a way to do this see the wiki page http://wiki.roblox.com/index.php?title=API:Class/Players/PlayerAdded

In studio you have to do it like this underneath.

local Players = game:GetService("Players")

function onPlayerAdded(player)
     print(player.Name .. " has entered the game")
end

--When a player joins, call the onPlayerAdded function
Players.PlayerAdded:connect(onPlayerAdded)

--Call onPlayerAdded for each player already in the game
for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end

Maybe this helps i do not know yet how to store the charachter names. I think you should return the function then add the return in a table.

Ad

Answer this question