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

Chatted returns nil? Can I have help? (This is a question, scriptinghelpers. let me ask it)

Asked by 4 years ago

This question has been solved by the original poster.

(im doing team create with my friend) I'm trying to make a chatted event yet when I try try to do anything with the message it returns it says it's nil:

attempt to call a nil value

heres my script: (by the way i've tried changing the 6 to 7 and 5 yet nothing changed)

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        if msg:Sub(1,6) == "/e test" then
            print('Wowies!!!')
        end
    end)
end)

0
from the parentheses in the title, WANNA JOIN MY RIOT DUDE?! WE WANT ANSWERS WE WANT ANSWERS! STOP CLOSING QUESTIONS STOP CLOSING QUESTIONS! iVmk3 -143 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

it fixed itself for some reason the sub function was causing it to break

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Your issue is using :Sub and not :sub. Example using lua.org:

Input:

print(("string"):Sub(1,3))

Output:

input:1: attempt to call a nil value (method 'Sub')

Fixed input:

print(("string"):sub(1,3))

Output:

str

Answer this question