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

Break joints if not humanoid?

Asked by 9 years ago
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

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. M39a9am3R 3210 — 9y
0
Oh, now I see your title. Alright, just wait for my FloodCheck on answering to lift... M39a9am3R 3210 — 9y

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

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)
0
Thanks! SirKitten2000 0 — 9y
Ad

Answer this question