The fence will be one part, not in a model. I need help making the fence unanchor itself when it is hit at a certain speed by anything. Also for it to uncollide it self 5 seconds after it's hit, and also respawn 50 seconds later after it is hit in the exact position it was before it was hit. This would be a lot of help for me since I am just now learning to script.
Remember not to post things that ask to write the script. I'll give you a layout but I won't write it for you.
First, I would make the surfaces glue or studs or something so that it breaks when under enough stress, not unanchor itself. This means you have to unanchor the whole thing so it breaks.
Next, simply write a line that changes the property after 5 seconds (script.Parent.CanCollide = false).
Finally, put a clone of it in lighting in the same location, and clone it into workspace after 50 seconds.
Hopefully this will help.
I could possibly answer this but I'm not sure about it being hit at a certain speed, is this going to be hit by the player or a object (for example your in a car and you go full speed ahead on the fence)
Well basically you have to click surfaces in the top right corner of the new studio and the click "add weld" Then put it on the surface of 1 part of the fence, you then copy it and add the parts to each other, I would say that the effect works better with a brick wall.
Forgot trying to do it at a certain speed. Your just trying to be too specific. If you're trying to do this by say a bullet from a gun, rename the bullet something like "fenceCrusher" and then inside of the fence put something along the lines of:
function onHit(part) if part.Name == "fenceCrusher" then script.Parent.Anchored = false local v = Instance.new"BodyVelocity", script.Parent) v.velocity = Vector3.new(math.random(1, 5),math.random(1, 5),math.random(1, 5)) wait(0.5) v:Destroy() --Optional script.Parent.CanCollide = false end script.Parent.Touched:connect(onHit)
You can keep a copy of the fence in ServerStorage for respawning it. As for speed, that would be hard unless the object was a vehicle. Here's my attempt:
script.Parent.Touched:connect (function (hit) if hit.Parent:FindFirstChild ('VehicleSeat') then -- check for a vehicle if hit.Parent.VehicleSeat.Speed == 50 then -- Speed check, change to fit your needs. script.Parent.Anchored = false -- TIMBER!!! wait (5) script.Parent.CanCollide = false wait (50) game.ServerStorage.Fence:Clone ().Parent = Workspace script.Parent:Destroy () end end end)
After a looooong time, I have figured it out myself after learning a lot more scripting. Basically what this script does is that when there is an object moving a certain speed through the detection box of a street lamp, it would make the streetlamp invisible and turn it's collisions off, and then clones a streetlamp that is not anchored and falls apart on runtime that is in the ReplicatedStorage. It then places the clone in the streetlamp's position. This gives the illusion that you smashed it.
After 5 seconds, it removes the debris. After 25 seconds, the streetlamp becomes visible again and it's collisions turn back on!
lamp = script.Parent.Parent.Lamp dupe = game.ReplicatedStorage.BrokenLamp debounce = true isBroken = false function Disappear () local a = lamp:GetChildren() local light = script.Parent.Parent.Lamp.Light.PointLight if debounce then debounce = false for i = 1,#a do if a[i]:IsA("Part") or a[i]:IsA("TrussPart") or a[i]:IsA("WedgePart") then a[i].Transparency = 1 a[i].CanCollide = false end end light.Enabled = false dupe:Clone().Parent = script.Parent.Parent isBroken = true local lampPos = lamp:GetPrimaryPartCFrame() script.Parent.Parent.BrokenLamp:SetPrimaryPartCFrame(lampPos) wait(5) script.Parent.Parent.BrokenLamp:Destroy() wait(25) for i = 1,#a do if a[i]:IsA("Part") or a[i]:IsA("TrussPart") or a[i]:IsA("WedgePart") then a[i].Transparency = 0 a[i].CanCollide = true end end light.Enabled = true wait(0.2) debounce = true isBroken = false end end script.Parent.Touched:connect(function(otherPart) if(otherPart.Anchored == false and otherPart.CanCollide == true and otherPart.Velocity.magnitude > 50) then if (isBroken == false) then script.Parent.hit:Play() end Disappear() end end)