How fix this? //FireClient can only be called from the server\
Game Explorer: https://gyazo.com/c1a27b624962cc329141890a46dcdac7
Script -
game.Players.PlayerAdded:connect(function(player)
local ChatBox = game.ReplicatedStorage.ChatHandler.ChatHistory:Clone()
ChatBox.Parent = player.PlayerGui:WaitForChild("GameGui").Chat
ChatBox.Name = "ChatBox"
end)
Script -
game.ReplicatedStorage.ChatHandler.NewMsg.OnClientEvent:connect(function()
--// My LuaScript
end)
workspace.ChildAdded:connect(function(object)
local NewPlayer = game.Players:playerFromCharacter(object)
if NewPlayer then
--// My LuaScript
end
end)
LocalScript -
local plr = game.Players.LocalPlayer
local chat = game.ReplicatedStorage.ChatHandler.ChatHistory
local last
function newChat(msg,plr)
--// My LuaScript
end
game.Players.LocalPlayer.Chatted:connect(function(msg)
newChat(msg, plr) print("newChat")
game.ReplicatedStorage.ChatHandler.NewMsg:FireClient(plr, msg) print("FireClient")
end)
In Studio: https://gyazo.com/fb48f2bc69b44d253d821a93a637511f In Game: https://gyazo.com/5bf329bc9840f44429119ca6acb2ecb7

1 comment
Remember, the Client is every Player in the game. The Server is the one thing that connects all the Players together.