Does somebody know why the text gui does not work? I would like to come up with a gui for 5 seconds to tell wich player won the obby. But I have no idea why this won't work. Can somebody help me/explain it?
finish.Touched:Connect(function(hit) local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if player then if not debounce then debounce = true player.leaderstats.Carrot.Value = player.leaderstats.Carrot.Value + 1000 print(player.Name.." has won the Carrot Obby and recieved 1000 Carrots!") for _, plr in pairs(game:GetService("Players"):GetPlayers()) do if plr.Character then plr.Character.HumanoidRootPart.CFrame = spawnpoint.CFrame print("All players have been teleported to: "..spawnpoint.Name) end end game.StarterGui.ObbyGui.WinText.Text = (player.Name.." has won the Carrot Obby!") game.StarterGui.ObbyGui.WinText.Visible = true wait(5) debounce = false game.StarterGui.ObbyGui.WinText = false end end end)
Whenever you want to change the player's UI in real time, use PlayerGui
, which can be accessed via player.PlayerGui
. StarterGui
acts as a template which is cloned into PlayerGui upon the player being loaded.
Ok so the problem is game.StarterGui it is not good to do anything to gui from the server, if you rlly need to change the player's gui from the server then use a remote event that fires a client or fires all clients.
game.StarterGui.ObbyGui.WinText.Text = (player.Name.." has won the Carrot Obby!") game.StarterGui.ObbyGui.WinText.Visible = true wait(5) debounce = false game.StarterGui.ObbyGui.WinText = false
You could use a remote event instead, I put a local script inside of the gui and a script inside of part:
--Script(Server) local winner=game.ReplicatedStorage.winner script.Parent.Touched:Connect(function() game.ReplicatedStorage.ShowGuiFromServer:FireAllClients() end)
Now this is the Local script inside the gui:
--Local Script Client game.ReplicatedStorage.ShowGuiFromServer.OnClientEvent:Connect(function() script.Parent.Visible=true script.Parent.Text="The winner is ".. game.ReplicatedStorage.winner.Value wait(10) script.Parent.Visible=false script.Parent.Text="" end)game.ReplicatedStorage.ShowGuiFromServer.OnClientEvent:Connect(function() script.Parent.Visible=true script.Parent.Text="The winner is ".. game.ReplicatedStorage.winner.Value end)