Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is my chat script having this error message?

Asked by 10 years ago

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'
0
Why do you have an 'if on line 6? RedCombee 585 — 10y
0
I want it to detect if another person chatted, then destroy the current message so the messages won't build up on each other. TroytheDestroyer 75 — 10y
1
I'll tell you - that's definitely not the way to do it. RedCombee 585 — 10y
0
Then, what is? TroytheDestroyer 75 — 10y
0
Also, it's not creating a hint every time someone chats. TroytheDestroyer 75 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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)
0
Thanks! i'll test it. TroytheDestroyer 75 — 10y
0
doesn't do anything. TroytheDestroyer 75 — 10y
0
Did you define "player"? bobafett3544 198 — 10y
0
yep. TroytheDestroyer 75 — 10y
View all comments (2 more)
0
oh you forgot to capitalize the `workspace`. TroytheDestroyer 75 — 10y
Ad

Answer this question