Hi all, I’ve been trying to make a tool that can be toggled on and off with a click. When it’s considered “active”, it fires a remote event on the server, that proceeds to fire a remote event on all connected clients and tells them which player fired the remote event.
The listener script is supposed to detect whether the target player has chatted a specific message, however the .Chatted event is not firing:
local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS.CursedSpeechFX.SpeechRemote
local toggleTable = {}
RemoteEvent.OnClientEvent:Connect(function(Player)
if Player then
local active = toggleTable[Player.UserId] or 1
if active == 1 then
toggleTable[Player.UserId] = 999
print("speech on")
Player.Chatted:Connect(function(msg)
if msg == "explode" then
print("exploding")
end
end)
task.delay(1, function()
toggleTable[Player.UserId] = 2
end)
elseif active == 2 then
toggleTable[Player.UserId] = 999
print("speech off")
task.delay(1, function()
toggleTable[Player.UserId] = 1
end)
elseif active == 999 then
return
end
end
end)
Does anyone know why this is the case? All help would be appreciated including alternate routes I could go about this. I’ve asked the AI Assistant for a bit and while it’s provided solutions for me in the past it hasn’t given me anything for this.