Help with a script telling if a player is in a game or not

Hello,

I wanted to make a script that, once I join a game, a TextLabel’s Text on a SurfaceGui would change to “Status: ForegoingTyler12943 is in this server!” and when I leave, “Status: ForegoingTyler12943 is not in this server.”. I could not make my script work. The text would not change. My script looks like this:

if game.Players.LocalPlayer.Name == "ForegoingTyler12943" then
	game.Workspace.BillboardGui.SurfaceGui.TextLabel.Text = "Status: ForegoingTyler12943 is in this server!"
else
	game.Workspace.BillboardGui.SurfaceGui.TextLabel.Text = "Status: ForegoingTyler12943 is not in this server."
end

Can you please help me find out how to make this script work?
Thanks!

the billboard gui text should be defaulted to “not in this server”

-- regular script
game:GetService("Players").PlayerAdded:Connect(function(player)
if player.Name == "Chad" then
workspace.BillboardGui.Text = "Status: ForegoingTyler12943 is in this server!"
end
end
game:GetService("Players").PlayerRemoving:Connect(function(player)
if player.Name == "Chad" then
workspace.BillboardGui.Text = "Status: ForegoingTyler12943 is not in this server."
end
end
2 Likes

Always answer these when making a post about fixing a script:

  • What type of script is it? (however, it is very evident here that it is a local script. If it isn’t, there’s your problem – normal scripts don’t have a local player)
  • Where is the script parented?
  • Are there any errors in the output pertaining to the script(s) you’re having issues with?

A better solution would be to use a normal script, see if a player joined with PlayerAdded, check if it’s that player, and update the label on the server, as mooneye has done it. However, a remote doesn’t seem to be necessary for the case

1 Like

With a little bit of modifying, I was able to make your script work! Thanks so much man!

1 Like