So i'm trying to get my chat script to say when I join the game but it's not working. The console doesn't show any errors, but when I join, it doesn't say the message I want it to in my chat.

local Players 				= game:GetService("Players")
local GroupId = 1233617

game.Players.PlayerAdded:connect(function(plr)
	local Rank = plr:GetRankInGroup(GroupId)
	local Role = plr:GetRoleInGroup(GroupId)
	
if Rank == 255 then
	local player = Players:FindFirstChild(plr.Name)
		if plr.Name == "centerspell" then
			_G.sysMsg("The Owner "..plr.Name.." has joined the server!", "Royal Purple")
		end
	end
end)

This defines the function in a different script.

function _G.sysMsg(msg,type)
	local title = ""
	local def=BrickColor.new(type)
	local v=Instance.new("StringValue")
	v.Name = "Message"
	v.Value=msg
	local col=Instance.new("Color3Value",v)
	col.Name="Color"
	col.Value=def.Color
	game.Debris:AddItem(v,3)
	
	local gui=game.StarterGui["ChatGUI"].Chat
	local t1=gui.Text1
	local t2=gui.Text2
	local t3=gui.Text3
	local t4=gui.Text4
	local t5=gui.Text5
	local t6=gui.Text6
	local t7=gui.Text7
	local t8=gui.Text8
	local t9=gui.Text9
	
	t1.TextColor3=t2.TextColor3
	t1.Text=t2.Text
	t2.TextColor3=t3.TextColor3
	t2.Text=t3.Text
	t3.TextColor3=t4.TextColor3
	t3.Text=t4.Text
	t4.TextColor3=t5.TextColor3
	t4.Text=t5.Text
	t5.TextColor3=t6.TextColor3
	t5.Text=t6.Text
	t6.TextColor3=t7.TextColor3
	t6.Text=t7.Text
	t7.TextColor3=t8.TextColor3
	t7.Text=t8.Text
	t8.TextColor3=t9.TextColor3
	t8.Text=t9.Text
	t9.TextColor3=col.Value
	t9.Text=v.Value
	
	v.Parent=workspace.ChatRecorder
end

2 comments

0

In the function defined, you need to see if it's really the StarterGui you want to access on line 12, and on line 9 you need to check if you actually need def.Color or just def. Also, consider using a module script instead of a global function.

0

I'm certain that everything is correct