I'm making this custom chat thingy and my script got a weird error. here is my script: (its in serverscrptservice)
player.Chatted:connect(function(msg) local m = Instance.new("Hint") m.Parent = game.Workspace m.Text = (msg) wait(1) if player.Chatted:connect(function(msg) m:Destroy() end) end) -- expected 'then' got end end)
I changed end)
to end
but it is still not working so I changed it back. any ideas?
Thanks for reading!
I also added then
to it but then it said
Expected identifier got 'then'
You can't use conditional statements (if and then statements) with functions. Also, what the error meant is your forgot to put a "then." Here's a better version of your script:
player.Chatted:connect(function(msg) if not workspace:FindFirstChild("PlayerMessageHint") then local m = Instance.new("Hint", workspace) m.Name = "PlayerMessageHint" m.Text = msg elseif workspace:FindFirstChild("PlayerMessageHint") then workspace:FindFirstChild("PlayerMessageHint").Text = msg end end)