if hit.Name == "hitbox" then
print('deleted')
print(hit.Name)
hit.Parent:Destroy()
so i have this this where it assigns number hitbox like hitbox1 hitbox2
and im wondering how could i just check the number instead of if hitbox1 if hitbox2 if hitbox3 and so on
local db = false
script.Parent.Touched:Connect(function(hit)
local str = string.gsub(hit.Name, "hitbox", "")
print("hitbox" ..str)
if db == false then
db = true
if hit.Name == "hitbox" ..str then
print('deleted')
print(hit.Name)
hit.Parent:Destroy()
end
end
wait(1)
db = false
end)
this is what i’ve tried but the string is just printing as hitbox(number) instead of removing hitbox
no what the script you sent would be doing is getting the hit.name (which is hitbox1234) and finding the numbers and getting rid of them. what im trying to do is get the numbers
but based on the source of where i found it,
what “%D” does is get all the characters that is not a digit,
and using string.gsub we can remove all that characters that isnt a digit and change them into the last parameter of the string.gsub
local hitboxNo = print(string.gsub("hitbox1234", "%D", ""))
print(hitboxNo) -- 1234