How do I make a object become unanchored when you hit it?

I’m trying to make a game where objects are unanchored when they are hit by people / gun bullets. My initial thought would be to do

script.Parent.Touched:connect(function()
script.Parent.Anchored = false

This doesn’t work though. Is there another physics event that is supposed to make this work? Thank you

1 Like

Try this.

script.Parent.Touched:Connect(function(WhoTouched)
if game.Players:GetPlayerFromCharacter(WhoTouched.Parent) then -- Checking if any member of the player's character touched the part and taking the player from that member
script.Parent.Anchored = false -- Anchored to false
end
end)
3 Likes

Your code should unanchor the part, but keep in mind that it will unanchor the part after it’s been hit by the moving player/object. There will be no transfer of momentum because the part was technically still anchored when it was hit. If you want the object to move in response to the collision, you either need to unanchor it before the collision, or you need to apply the force yourself.