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

String:sub not working?

I made a part of a function that will kill someone if they do not have the name of the third letter and above of a model. The model in question would be called TB[Name], but this script kills everyone regardless of their name. Here is the script:

local nm = hit.Parent.Parent.Name
		local tb = script.Parent.Parent.Name
		if nm ~= tb:sub(3) then
		hit.Parent.Humanoid:TakeDamage(100)
		script.Parent.hit:Play()
		wait(1)
	end
	end

There are no errors in the output. Am I using :sub correctly?

1 answer

✓ Accepted answer

I belive it is typed

string.sub()

1 comment

0

It appears you are correct, but now I get this error: Workspace.TBPlayer.shield.shieldscript:8: bad argument #2 to 'sub' (number expected, got no value) (there IS a number in the parenthesis...)

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