How can I make a model's welds to break by touching terrain?

I have been trying to write a script to break the welds of my Spaceship if it touches the terrain below it.

Unfortunately, the script didn’t work and I ended up with something more like this occurring:

This is the script. It produces no errors in the output, but doesn’t do its job.

this is the script I am using:

local Plane = game.Workspace.Plane1
local Weld = game.Workspace.Plane1.root.BTWeld
local terrain = game.Workspace.Terrain

function OnTouch(Terrain)
	game.Workspace.Plane1.BTWeld:Destroy()
end
	

Is this the whole script? If it is, it won’t really do anything since it’s not actually running the function.

yes. I’m new to scripting so I just winged it. Not sure what the problem is for it tho.

Hey, I’m glad to know you’re getting into scripting. I’m sorry you’re having issues, try this code:

workspace.Terrain.Touched:Connect(function(hit)
	for i,v in pairs(hit:GetDescendants()) do
		if v:IsA("Weld") then
			v:Destroy()
		end
	end
end)

What this script does is it checks for any welds inside of a model, or a part that touches the Terrain. If it finds any, then it will delete the weld. If not, then nothing will happen. Good luck!

Edit: Also, regarding the script you tried at first. The reason why it didn’t work is because you’re defining a function, but not actually calling it once the plane hits the Terrain.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.