Can somone help me with my global chat? (No errors)

That is the serverscript

script.GlobalChatLocal.Parent = game:GetService('StarterPlayer').StarterPlayerScripts
script.ChatMsg.Parent = workspace
local data = game:GetService('DataStoreService')
local datastore = data:GetDataStore('GlobalChatData')

local key = 'RecentChatMsg'

datastore:OnUpdate(key, function(msg)
	workspace.ChatMsg:FireAllClients(msg,Color3.new(1,1,1))
end)
workspace.ChatMsg.OnServerEvent:connect(function(plr,msg)
	datastore:SetAsync(key,('['..plr.Name..']: '..msg))
end)

Thats the local script

print'global chat system clientside loaded'
workspace.ChatMsg.OnClientEvent:connect(function(txt,color)
	for _,p in pairs(game.Players:GetPlayers()) do
		local plrc = string.len(p.Name)
		local plrname = string.sub(txt,2,plrc+1)
		if plrname == p.Name then return end
	end
	pcall(function() game:service("StarterGui"):SetCore("ChatMakeSystemMessage",{Text=txt})
	end)
end)
game.Players.LocalPlayer.Chatted:connect(function(msg,rec)
	if rec then return end
	workspace.ChatMsg:FireServer(msg)
end)

1 comment

1

Have you tried debuging your script?