Still have questions? Join our Discord server and get real time help.
0

# 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
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?

0
RemoteEvents Avi_i 2 — 5mo

1
herrtt 387
5 months ago
Edited 5 months ago

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)

0
Thank you! Ps. I need at least 25 reputation to be able to upvote. Sorry! Tommmmmey 13 — 5mo
0
i could upvote for you speedyfox66 196 — 5mo