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

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

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

1 comment

0

from the parentheses in the title, WANNA JOIN MY RIOT DUDE?! WE WANT ANSWERS WE WANT ANSWERS! STOP CLOSING QUESTIONS STOP CLOSING QUESTIONS!

2 answers

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

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

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