Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Can someone help me with this player left message?

Asked by 3 years ago

So, I made a code where if you joined message pop-up in chat that worked Ok, But how about the left message. I tried multiple times and it didn't work what's wrong with it?

This script in ServerScriptService


local MessageEvent = game.ReplicatedStorage.PlayerLeftMessageEvent game.Players.PlayerRemoving:Connect(function(Player) repeat wait() until Player.Character or Player.CharacterRemoving:Wait() local text = "{System} "..Player.Name..", Has left to the game" local color = Color3.fromRGB(255,0,0) local font = Enum.Font.Cartoon MessageEvent:FireAllClients(text,color,font) end)

What wrong with that's it's not working??

This for StarterGUI

local StarterGui = game:GetService("StarterGui")
local MessageEvent = game.ReplicatedStorage.PlayerLeftMessageEvent


MessageEvent.OnClientEvent:Connect(function(text,color,font)
    StarterGui:SetCore("ChatMakeSystemMessage",{
        Text = text,
        Color = color,
        Font = font
    })
end)
0
Please, give us the error! Qariter 110 — 3y
0
It doesn't appear any errors in Scrpit Analysis or logs what do i do? thekiler_king 17 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can delete the server script and the event, this is a 100% client script

local SG = game:GetService("StarterGui")
local Players = game:GetService("Players")
Players.PlayerRemoving:Connect(function(Player)
    SG:SetCore("ChatMakeSystemMessage", {
        Text = "{System} "..Player.Name.." has left the game",
        Color = Color3.fromRGB(255,0,0),
        Font = Enum.Font.Cartoon
    })
end)

This detects the player removing on the client. Keep in mind this won't work if a player gets disconnected from the game.

Ad
Log in to vote
0
Answered by
zane21225 243 Moderation Voter
3 years ago

On line 4, you put:

repeat wait() until Player.Character or Player.CharacterRemoving:Wait()

Your script is probably waiting infinitely here, hence why any of the code isn't running.

You don't really have to put this line into your code, as once the player removes they're essentially already removed from the game. There is no point in calling the character after.

Answer this question