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

How to find PlayerGui and leaderstats on a server script?

Since I started programming roblox lua I always had this problem and it's time to fix it. I tried it different ways: 1.

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local playerGui = player:WaitForChild("PlayerGui")
end)
game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:FindFirstChild("leaderstats")
	local playerGui = player:FindFirstChild("PlayerGui")
end)
game.Players.PlayerAdded:Connect(function(player)
	wait(5)
	local leaderstats = player:WaitForChild("leaderstats")
	local playerGui = player:WaitForChild("PlayerGui")
end)
game.Players.PlayerAdded:Connect(function(player)
	wait(5)
	local leaderstats = player:FindFirstChild("leaderstats")
	local playerGui = player:FindFirstChild("PlayerGui")
end)

I don't have more ideas on how to do it, so I depend on whoever answers my question. Thanks.

9 comments

0

I think that is literally the only way

0

it doesn't work xd

0

Is there a script anywhere that adds the leaderstats in the Player?

0

@nampha666yes

0

Your first option is the best.

0

yes but it doesn't work

0

You cannot get gui's from server scripts.

0

Program client sided.. send remotes to the server..

0

rule 1: never trust client

1 answer

The PlayerGui is client sided, meaning if you try to access anything in it from the server, you won't find anything. Stick to using LocalScripts and ModuleScripts (in the StarterGui) to do things on a Player's screen.

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