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

Touch Function And Find Name? [ANSWERED]

Asked by 8 years ago
Edited 8 years ago

On line 6, it says "Noob". How do you make it so that as long as the first letters are "Noob", if the noob is named like "Noob 1" or "Noob 2", but more importantly a complicated name after "Noob", it still damages them because the first letters are "Noob". Sorry if it doesn't make sense. It's really hard for me to explain this. xD Anyways, thanks for reading!

local debounce = false

function onTouched(hit)
    if not debounce then
        debounce = true
        if hit.Parent.Name == "Noob" then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5
            wait(0.5)
            debounce = false
        end
    end
end

script.Parent.Touched:connect(onTouched)
1
if hit.Parent.Name:sub(1, 4) == "Noob" then Pyrondon 2089 — 8y
0
What if the noob has a complicated name after it? Like "Noob Lv 1 HP 100/100" GatitosMansion 187 — 8y
0
OH! It works I put "sub" as "Sub" so it wasn't working lol. Thanks. GatitosMansion 187 — 8y

Answer this question