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

How can I show message to just the player who has died?

Hi

How can I show a status message to only the players who die and are sent to the lobby. In my case I set the status to "Waiting for enough players" while the players are in the lobby. But this status message will also pop up for the players still in the game. Anyone know how I can just show a status message to players in the lobby?

In my main script I have this (part of code):

-- Game loop
for i = GameLength,0,-1 do
	for j, player in pairs(plrs) do
		if player then
			character = player.Character
			if not character then
				--Left the game
			else
				if character:FindFirstChild("GameTag") then
					--They are still alive
				else
					--They are dead
					table.remove(plrs,j)
					Status.Value = "Waiting for enough players"
					--print(player.Name.." has been removed from the game")
				end
			end
		else
			table.remove(plrs,j)
			Status.Value = "Waiting for enough players"
			--print(player.Name.." has been removed from the game")
		end
	end
end

I also have a status localscript that shows the current status (as an image):

local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
if Status.Value == "Waiting for enough players" then
	print("StatusPage: Waiting for enough players")
	StatusImage.Visible = true
end

But this code will show 'Waiting for enough players' also for the players still in the game. How to just show for the players in the lobby?

1 comment

0

RemoteEvents

1 answer

✓ Accepted answer

Well first of you might need to check if they are in game on the client (like you did on the server). This snippet checks if the character has spawned and if GameTag is not in the Character.

I am not sure if you check this each second or so, but if not you might want to do it as this will only run once.


local p = game:GetService("Players").LocalPlayer

if p.Character and p.Character:FindFirstChild("GameTag") == nil then
	local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
	if Status.Value == "Waiting for enough players" then
	    print("StatusPage: Waiting for enough players")
	    StatusImage.Visible = true
	end
end

(if this seemed to work out an upvote would been appreciated)

2 comments

0

Thank you! Ps. I need at least 25 reputation to be able to upvote. Sorry!

0

i could upvote for you

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