New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 5 days ago

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?

0
RemoteEvents Avi_i 2 — 5d

1 answer

Log in to vote
1
Answered by
herrtt 226 Moderation Voter
5 days ago
Edited 5 days 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 6 — 4d
0
i could upvote for you speedyfox66 93 — 4d
Ad

Answer this question