Help on this gun thingy

i need help with this script because im modifying it what is wrong here because its not killing/damaging the player when shot

1 Like

so theres 2 possibilities

first, since the ball is deleting itself after 1 second, it could be getting deleted before hitting anything

and second, which is more likely, the ball is hitting players’ accessories and then the connection is getting disconnected.

you can fix that by adding this

if hit.Parent:IsA("Accessory") then
	humanoid = hit.Parent.Parent:FindFirstChild("Humanoid")
end
2 Likes

where must i add it must i add it under all the code?

you put :findFirstChild() instead of :FindFirstChild(), might be the problem but i might also be wrong

1 Like

Wait, I’ve just realized there’s soo much wrong in the code… pretty sure it was AI generated…

There can be lots of things going wrong here.

Try this and tell me what the output says.

function onTouched(hit)
  local parentModel = hit:FindFirstAncestorWhichIsA('Model')
    if not parentModel then
      print('No model found')
    else
      local hum = parentModel:FindFirstChild('Humanoid')
        if not hum then
          print('No hum found')
        else
          hum:TakeDamage(damage)
        end
    end
end
1 Like

tho the code i found it but thanks for helping and the code was from 2013