Hi, I have scripts that utilize the Player.Chatted function and for some reason they only work sometimes and the times they don’t work, they give no error. I’ve tried in multiple games and this function only works sometimes.
This is one of the scripts:
plr.Chatted:Connect(function(msg)
if msg:lower() == "-ifeadmin" then
event:FireClient(plr,"accessifeadmin")
end
end
)
end)
This works most of the time but sometimes it doesn’t.
Can someone please help me figure out why this is the case?
I’m unaware of the issue here as it should work completely fine - if this is a part of the code, then I’m assuming there’s an error above your code or under.
I would suggest posting the rest of the code (if any) and any errors that you encountered. The code will work as is, which means there’s an underlying problem that isn’t presented in your post.
I didn’t encounter any errors. It worked sometimes, other times it didn’t. The code before it always works fine too, so I don’t think that could be a problem.
Just a general question, the code looks fine to me expect for the organization e. Are you spelling the exact word each time? I know it sounds dumb but it might be the problem.
I’ve also brought it into my studio and there is a error.
Here is some update code.
plr.Chatted:Connect(function(msg)
if msg:lower() == "-ifeadmin" then
event:FireClient(plr,"accessifeadmin")
end
end)
The problem was that you had a extra end for some reason, I may be wrong as you only included that part of your code but hope this helps!
I’m not really sure what is wrong here, since you don’t have to provide all arguments for TweenPosition. Try make it so it prints something when the client is fired to check if it even responds.
The server didn’t pick it up. I made it print both on the server and client and it didn’t work on either, however, on the occasions it did work, it obviously printed.
plr.Chatted:Connect(function(message, recipent)`
local message = "-ifeadmin
if string.lower(tostring(message)) == tostring(message) then
event:FireClient(plr, "accessifadmin")
end
end)
A big help would be to describe what “sometimes” means. If for instance you told us that when it
doesn’t work for a player, then it never works until that player rejoins the game, that would give us a
much clearer picture. If you told us that for the same player without rejoining works and sometimes
doesn’t, that would be less clear. Did you try printing all messages, to see if your cmd is indeed being
received, but possibly some other junk is in the string as well?
Hi, when I say “sometimes” I mean it doesn’t work for any player in the game until the server resets and hopefully you get lucky. As for your second question, I made it print any message received by Player.Chatted and in the times it didn’t work, nothing was printed.