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

How to make this NOT break tools?

Asked by 10 years ago

Whenever I fire the weapon with this script, the weapon falls apart. It's a SBC cannon from Serious Sam (I Know, pretty serious, right? Lol) and whenever I fire it, the gun itself breaks. Anyway to rewrite it so it doesn't make the gun fall apart?

function onTouched(hit)
hit:BreakJoints()
end

connection = script.Parent.Touched:connect(onTouched)

2 answers

Log in to vote
0
Answered by 10 years ago

The "connection" are being triggered, because the bullet are touching the weapon. Thats what I think.

Ad
Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

I'd make sure the hit isn't a child of a Tool.

function onTouched(hit) -- remember to indent scopes for clean looking code :)
    if not hit.Parent:IsA("Tool") then
        hit:BreakJoints()
    end
end

connection = script.Parent.Touched:connect(onTouched)

Answer this question