Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

Put your script in this thread in code tags, please.

1 answer

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")

2 comments

0

Another question, what happens when an assert() is true? Does it error or stop the rest of the code?

0

Also i've tried the speakeradded thing, unfortunatly it still doesnt work returning another error.

This discussion is preserved as it was. New answers, comments, and votes are closed.