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

String:sub not working?

Asked by
JJ_B 250 Moderation Voter
8 years ago

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

Log in to vote
1
Answered by
Poine 30
8 years ago

I belive it is typed

string.sub()
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...) JJ_B 250 — 8y
Ad

Answer this question