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

Why won't the message for this disappear? (ANSWERED)

_G.Players = game:GetService("Players")

for i,v in pairs (game.Players:GetPlayers()) do
	if v.Name == "RadiantSolarium" and v:IsA("Player") then
		local M = Instance.new("Message", game.Workspace)
		M.Text = "The Mighty Pickle has arrived!"
	end
end

The message that spawns won't de-spawn.

1 answer

✓ Accepted answer

This is only running right when the server is started. If you are not the first player to join the server, then the script will not notice you entered the game because it will never run again.

To fix this, we need to create a function. We have to use the PlayerAdded event so the function fires when any player enters the game. Then we can check if the player's name is RadianSolarium and create the message from there..

_G.Players = game:GetService("Players")

function playerEntered(player)
    if player.Name == "RadiantSolarium" then
        local M = Instance.new("Message", game.Workspace)
        M.Text = "The Mighty Pickle has arrived!"
        wait(4)
        M:Destroy()
    end
end

game.Players.PlayerAdded:connect(playerEntered)

Here is more information on functions. Here is more information on events. Here is more information on PlayerAdded.

If I helped you out, be sure to accept my answer!

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