Destruction game destroying people

Okay, so I made a destruction game, and it works because the stuff to destroy is welded together, and the slingshot’s script says if touching something, unweld it. So it works, and it is fun, but if one of the slingshot’s pellets bounces and hits the human, their parts get unwelded, too! Is there a way to make the humanoids impossible to unweld, or maybe edit the script to only break blocks with a certain name? This is the script:

function onTouched(hit)
hit:BreakJoints()
wait(0.5)
pellet:Destroy()
end

here is the game:
https://www.roblox.com/games/5945364266/Break-Things?refPageId=e0543179-16fb-40ef-9ccf-8eba353b818b

3 Likes

if hit.Parent:FindFirstChildOfClass(“Humanoid”) then return end

Put this right before breakjoints and it should fix it.

You just need something to tell it whether it’s a player or not

Alright, thanks! Let me try it…

The pellet might not get destroyed this way so your probably better off doing

if not hit.Parent:FindFirstChildOfClass(“Humanoid”) then

— code here

End

And then put the destroy pellet here after the end

It wont unweld stuff Anymore…

I tried it, but now the pellets won’t unweld anything and they won’t go away

Alright this should do it.

if hit.Parent:FindFirstChildOfClass(“Humanoid”) then
else
—break code here
end
—remove pellet code here

Sorry about that

Hm, still doesn’t work…
Did I do it right?

Wait goes below the end so it does it no matter what

I did that, and still nothing unwelds and the pellets dont delete… Thanks so much for trying to help, though! I’ll keep trying

Wow I just figured it out I’m so sorry

Replace the .findfirstchildofclass with a :findfirstchildofclass

I feel so bad now

(It wasn’t working the whole time because I didn’t use : for :findfirstchild)

It still does the same thing… did I mess something up again?

Well the only other thing I can think of is if it’s breaking their tools or something or anything that’s parent isn’t the player

If it’s breaking tools you can just copy and paste the hit.Parent:FindFirstChildOfClass(“Humanoid”)
And replace humanoid with the Tool class.

Could it be with the
:FindFirstChildOfClass(“humanoid”)
?
Is there another way to identify a human?

Yeah you can just do FindFirstChild then it detects the name not the class

Well, I am stumped. Thanks so much for trying, though! It’s probably something I messed up

I got it! It was something I did wrong

I already had a similar script to detect humanoids

Sorry about this

Some other ways you could detect it is by hit.Name hit.Parent.Parent:FindFirstChild(“Humanoid”) etc

So like

If hit.Parent:FindFirstChildOfClass(“Humanoid”) or hit.Parent.Parent:FindFirstChildOfClass(“Humanoid”) then

I just changed it to do what I needed:


Yay!

1 Like