Chat script not working?

Hey everyone! Hope your are doing well, so today I was scripting a little thing, didn’t realize I would have this much trouble with it but basically, when a player joins, a message should appear saying that player joined with their name and when they leave it says the same thing except it says player left. For some odd reason, my scripts are not working. I’m sure it is a little minor mistake but here are both of my scripts…

This one is in SSS

local Rep = game:GetService("ReplicatedStorage")
local Added = Rep:WaitForChild("Added")
local Removing = Rep:WaitForChild("Removing")

game.Players.PlayerAdded:Connect(function(plr)
	Added:FireClient(plr, plr.Name)

end)

game.Players.PlayerRemoving:Connect(function(plr)
	Removing:FireClient(plr, plr.Name)
end)

Basically that one is just the script that controls the events to be used.

The next script is in StarterGui, this script just handles all the information for the events…

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Added = ReplicatedStorage:WaitForChild("Added")
local Removing = ReplicatedStorage:WaitForChild("Removing")
local startergui = game.StarterGui

Added.OnClientEvent:Connect(function(plr)
	print("Fired!")
	startergui:SetCore("ChatMakeSystemMessage",{
		text = "[SYSTEM]"..plr.Name.." has joined the game!";
		Color3.fromRGB(0, 255, 0);
		Font = Enum.Font.GothamBold;
		FontSize = Enum.FontSize.Size32;
	})
end)

Removing.OnClientEvent:Connect(function(plr)
	print("Fired other!")
	startergui:SetCore("ChatMakeSystemMessage",{
		text = "[SYSTEM]"..plr.Name.." has left the game!";
		Color3.fromRGB(170, 0, 0);
		Font = Enum.Font.GothamBold;
		FontSize = Enum.FontSize.Size32;
	})
end)

Those are both of my scripts, if anyone knows how to fix this(Because I am really new with using “ChatMakeSysttemMessage”) Please let me know! Thanks ahead of time :))

1 Like

First of all, I’m assuming you want these messages to be seen by all players. In that case, you need to use :FireAllClients(), not just :FireClient().

Try this change on the server and let me know if it works or not:

game.Players.PlayerAdded:Connect(function(plr)
	Added:FireAllClients(plr)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	Removing:FireAllClients(plr)
end)

lol, idk how I mixed that up, but it didn’t work, I think the reason why is because I’m getting an infinite yield… Infinite yield possible on ‘ReplicatedStorage:WaitForChild(“Added”)’

That means it can’t find any object named “Added” in ReplicatedStorage. Make sure your remote events are a direct child of ReplicatedStorage and are named “Added” and “Removing” (caps sensitive).

If this is already the case, can you screenshot your explorer view and send it here?

ohhhhhh, I see why, I have an events folder, and I did not define it. lmao, my bad, I will just remove the events folder so it is easier for me.

1 Like

Alright, so the print portion in my script did print, but the rest of the code under it, didn’t continue. So it didn’t say the player joined…

Here is my exp,

The parameters you sent seem to be a little wonky, the text index should be Text and the Color3 argument should be Color = Color3.fromRGB(170, 0, 0)

1 Like

Wow, I keep making those little mistakes, thank you :))

1 Like