I'm trying to modify some gui texts through a normal script located in workspace but when I test it i got the error: Attempt to index local 'player' (a nil value). I know this would not happen if i use a script inside the gui and put that Player = script.Parent.Parent.Parent but for some reasons i don't want to do it that way. Here's how the code looks like:
player = game.Players.LocalPlayer
PlyrGui = player.PlayerGui -- Here is the error ('player' (a nil value) )
Gui1 = PlyrGui:WaitForChild("Menu1")
function Action1()
-- Imagine here is all the funciton. lol
end
game.Players.ChildAdded:connect(Action1)
How I can make the computer find the player so then it can find the playerGui? Please help

1 comment
But I want to use this function not just when a player joins the game :(