How can I achieve a breakable prop?

I want to make a breakable prop (Eg: Signs, streetlights, ect)

Here is what I have so far:
local db = false

script.Parent.HitBox.Touched:Connect(function(hit)
if db == false then
db = true
print(hit)
script.Parent.Part.Anchored = false
end
end)

This works but the object only is sent flying when hit the second time. Any thoughts?

– Cheers – Creative Side-B

6 Likes

I don’t see any code which would make it be “sent flying” is this the entire thing?

1 Like

Is your hit box anchored as well? That would cause your part to go flying.

1 Like

I think he means it gets sent flying because the player hit it so hard.

2 Likes

Hello, sorry, I have configured the physical properties of the part to make it light and when hit it will act as if it goes flying a few meters.

1 Like

I’m having struggles with the code, is there a way to use RunService and check the frame of when the exact moment something collides with the hitbox?

1 Like

Since you’re printing hit via:
print(hit)

It should tell you when an object has interacted with the box (aka touching it)

1 Like

could you send a vid/gif? thatll be helpful lol

1 Like

Yep, just give me a second lol

2 Likes

It’s not letting me upload it here, so I’ve uploaded it to google drive :slight_smile:

it doesnt have enough time to unanchor.

this is a bad solution, but make the hitbox bigger for more time

I’ll see if that works, thanks for replying.

1 Like

Ok, it doesn’t work and it would be a bad solution too as you said.

ill look more into it lol ill get back asap

1 Like

Awesome thankyou so much, if there is a more advanced option, I’m all in.

you set db not to false try that

the db does nothing other than make sure my game doesn’t time out.

Please use 3 backquotes before and after your script to format it.
A Debounce Patterns | Roblox Creator Documentation is meant to keep something like a .Touched object from firing multiple times. You don’t have a wait(x) in your function to do that.
Also you set db to false outside the function, when the function is fired you check for false (good) and immediately set to to true (good) but as mentioned you need a wait(however many seconds) and after that you need to set db to false again.
And I would put the script in the Hitbox itself.

And are you getting the (hit) print the first time?

local db = false

script.Parent.Touched:Connect(function(hit)
     if db == false then
          db = true
          print(hit)
          script.Parent.Parent.Part.Anchored = false
          wait(1)
          db = false
     end
end)
1 Like

Dam, thanks this helps a bit, thankyou for your reply

Didn’t read correctly lol sorry, how can I get the frame the object was un anchored and the frame the hitbox was hit? and then house can I make it as soon as the box is hit the prop is un anchored?