Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make this NOT break tools?

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.