Hello, I am trying to make game where you find endings and it counts up how many you have on an gui. I put in script on part touched it goes to playergui and updates text there from 0/13 found to 1/13 found. It worked in startergui it updated the text but when i put it to playergui it doesnt do nothing.
script.Parent.Touched:Connect(function(part) if part.Parent:FindFirstChild("HumanoidRootPart") then script.Parent.Parent.Parent.Parent.Players.LocalPlayer.PlayerGui.EndingGui.Menu.Easyendings.oo13.Text = "1/13 found" end end)
LocalPlayer
can NOT be accessed via server-side.
It is the LocalPlayer of the client but since a script is not a client script, it obviously doesn't work
You can use GetPlayerFromCharacter()
script.Parent.Touched:Connect(function(part) if part.Parent:FindFirstChild("HumanoidRootPart") then local player = game.Players:GetPlayerFromCharacter(part.Parent) -- It gets a model and gets the player of the character if player then player.PlayerGui.Ending.Text = '1/13 found' -- I think you mean text end end end)
It is really unnecessary to go like script.Parent until it reaches game and do .Players.
You can easily use game.Players