Problem with destruction script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    What I am trying to make is that when a vehicle hits a building, the building breaks.

  2. What is the issue?
    The problem I’m having with itis that it wont break the building when it is touched by a vehicle.


if script.Parent.Touched:Connect(function(hit)
if hit.Candestroy then
script.parent.Anchored = false
script.Parent.Anchored = true
script.Parent.CFrame =
script.Parent. Orientation =

  1. What solutions have you tried so far?
    I have tried doing some bug fixes but I havent been able to fix it

Thanks for reading. :grin:

Hi, it seems like you are new to scripting. Before making complex things like this, try perfecting functions and if statements. Here is a scripting tutorial I suggest you watch.

To point out your mistake, you have an incomplete if statement right before the function. Also, you are missing the end for the second if statement:

wait you said it is touched by the vehicle and I suppose your vehicle is a model and the script is placed inside the model and you are calling script.Parent.Touched… Try indexing all the parts of the vehicle and then apply the touched event on each part

I have been putting it in all the parts of the vehicle

Opps, I didn’t see that when I was writing the script before :laughing: thanks for telling me about that.

1 Like