New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Messaging Service, Attempt to index a nil value on line 17?

Asked by 11 days ago

I need help, I've been looking for hours on how to fix this, I've also asked a tried to ask a few people with no success, the script I've made is for chat tags, but they don't work at all, the error is in the question title, I am very tired when I write this so don't mind my terrible English and whatnot here is the script. https://pastebin.com/BYid0YrX

Thanks in advance, Destroyer1234x.

0
Put your script in this thread in code tags, please. Sonnenroboter 310 — 11d

1 answer

Log in to vote
0
Answered by 11 days ago

I think this is because of the delay between the moment the player joins and until ROBLOX makes them a Speaker.

Instead try binding your function to SpeakerAdded in ChatService this way whenever your function runs, the speaker will always be there

One tip for you though is to use assert(), it's a good debugging tool and really easy to use. Basically if the condition is false it prints what you told it to and breaks, so like this:

assert(true,"This will never print because the condition is always true")
assert(false,"This will always print because the condition is always false")
print("This will not print because when assert if false, it breaks")
plr = game.Players:FindFirstChild("someReallyWeirdName")
assert(plr,"If this prints then the player doesn't exist and if the code runs it will error")
0
Another question, what happens when an assert() is true? Does it error or stop the rest of the code? Destroyer1234x 32 — 11d
0
Also i've tried the speakeradded thing, unfortunatly it still doesnt work returning another error. Destroyer1234x 32 — 11d
Ad

Answer this question