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

Text and Servers?

game.Players.PlayerAdded:connect(function(player)

	local hint=game.StarterGui.PlayerAdded.Hint
	hint.Text=player.Name.." has joined the game."
	wait(3)
	hint.Text=nil
end)


game.Players.PlayerRemoving:connect(function(player)
	local hint=game.StarterGui.PlayerAdded.Hint
	hint.Text=player.Name.." has left the game."
	wait(3)
	hint.Text=nil
end)

This is a normal script in serverscriptservice. The hint isnt actually a hint it is a textlabel. So the problem is that when the script runs it says the player has joined the game and the text just stays there. And when someone else joins the text should be replaced to the new person who has joined the game but it just stays there

1 comment

0

You have made the mistake of using StarterGui. https://scriptinghelpers.org/blog/common-mistakes#PlayerGui

1 answer

Hi! Your issue is using StarterGui. Your fixed script is here:

game.Players.PlayerAdded:connect(function(player)

for i,v in pairs(game.Players:GetChildren()) do
    local hint= v.PlayerGui.PlayerAdded.Hint
    hint.Text= player.Name.." has joined the game."
    wait(3)
    hint.Text= nil
end
end)


game.Players.PlayerRemoving:connect(function(player)
for a,b in pairs(game.Players:GetChildren()) do
    local hint=b.PlayerGui.PlayerAdded.Hint
    hint.Text=player.Name.." has left the game."
    wait(3)
    hint.Text=nil
end
end)

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