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

Break joints if not humanoid?

local breakjoints = true

function onTouched(hit)
	if (breakjoints == true) then
		wait(1)
hit:BreakJoints()
end
local humanoid = hit:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) then	-- if a humanoid exists, then
		breakjoints = false
	
	else breakjoints = true
end
end






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

Breaks joints even if it is a humanoid, not supposed to do that

2 comments

0

Are you just wanting to kill the Character, or are you trying to destroy everything but the character? Your code and explanation are kind of confusing and broad.

0

Oh, now I see your title. Alright, just wait for my FloodCheck on answering to lift...

1 answer

✓ Accepted answer

You should not need any variables in this function. Explanations are in the script. If you have questions, feel free to comment on this answer.

function onTouched(hit)
	if hit.Parent:FindFirstChild("Humanoid") then   -- if a humanoid exists, then
		print("Don't break those joints!") --Just to prove it works when a humanoid hits it and doesn't die.
	else
		hit:BreakJoints() --Hit is a part. If "hit" hit's the brick you're putting this script in, then "hit" will break joints.
	end
end

script.Parent.Touched:connect(onTouched)

1 comment

0

Thanks!

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