Tsunami script not detecting hit welds

Hi everyone, im working on a tsunami wave that destroys weldconstraints in the part it hit, however for some reason the weld isnt being destroyed or detected at all, does anyone know how i could fix this? thanks in advance !

local tsunami = script.Parent
local tws = game:GetService("TweenService")
local goalpos = tsunami.Position - Vector3.new(0 ,50, 700)

wait(10)

local tweeninfo = TweenInfo.new(20, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = tws:Create(tsunami, tweeninfo, {Position = goalpos})
tween:Play()

tsunami:GetPropertyChangedSignal("Position"):Connect(function()
	local touchingparts = tsunami:GetTouchingParts()
	for i, v in pairs(touchingparts) do
		if v:IsA("BasePart") then
			for _, v in pairs(v:GetChildren()) do
				if v:IsA("WeldConstraint") then
					v:Destroy()
				end
			end
		end
	end
end)

you use v twice, change it to something else in the for loops :D

1 Like

thanks for the suggestion, but sadly it didnt fix it :frowning:

Is this a server script or a local script? Also make sure to set the anchored property to false for each basepart :D

local tsunami = script.Parent
local tws = game:GetService("TweenService")
local goalpos = tsunami.Position - Vector3.new(0 ,50, 700)

wait(10)

local tweeninfo = TweenInfo.new(20, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = tws:Create(tsunami, tweeninfo, {Position = goalpos})
tween:Play()

tsunami:GetPropertyChangedSignal("Position"):Connect(function()
	local touchingparts = tsunami:GetTouchingParts()
	for i, v in pairs(touchingparts) do
		if v:IsA("BasePart") then
            v.Anchored = false
			for _, partChild in pairs(v:GetChildren()) do
				if partChild:IsA("WeldConstraint") then
					partChild:Destroy()
				end
			end
		end
	end
end)

Oh, and do you have multiple welds per part? If not, you can use FindFirstChildOfClass() :D

1 Like

yeah its a server script and the parts are already unanchored by default, i have multiple welds per part

I don’t see why it doesn’t work then… Any way I can have a barebones file of the game? I wanna figure this one out :P

1 Like

Wave.rbxm (8.5 KB)
heres an rbxm for the tsunami wave, you could just use some breakable house freemodel for the thing being destroyed

How are the welds structured? Can I just have one rbxm file of something, you can remove the color. For example a fence or something insignificant. Thanks!

Because the tsunami might be deleting the welds under a part, but there’s a weld under another parts that isn’t touched by the tsunami, holding the two together.

1 Like

house.rbxm (10.8 KB)
here you go, the welds are created with an autoweld script, the autoweld script isnt the problem though

I was thinking something like this
image

1 Like

uhhh so I found your issue

local touchingParts = tsunami:GetTouchingParts()
print(touchingParts)

doesn’t print anything, even when touching the house

1 Like

i see, for some reason it only detects seats and not parts on my end


Good news, progress… but still errors lol

1 Like

oh wow nice, could i know how you did this? i could probably just add a pcall function so the error doesnt halt the script

pcall? Wow you know more than me xD

local tsunami = script.Parent
local tws = game:GetService("TweenService")
local goalpos = tsunami.Position - Vector3.new(0, 0, -300)

wait(1)

local tweeninfo = TweenInfo.new(20, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = tws:Create(tsunami, tweeninfo, {Position = goalpos})
tween:Play()

tsunami:GetPropertyChangedSignal("Position"):Connect(function()
	
	local touchingParts = workspace:GetPartsInPart(tsunami)
	
	for _, touchingPart in pairs(touchingParts) do
		
		if touchingPart:IsA("BasePart") then
			
			for _, shouldBeWeld in pairs(touchingPart:GetChildren()) do
				if shouldBeWeld:IsA("WeldConstraint") then
					
					if shouldBeWeld.Part1 then -- this is how I solved the issue without the pcall
						for _, weld in pairs(shouldBeWeld.Part1:GetChildren()) do
							if weld:IsA("WeldConstraint") then

								weld:Destroy()

							end
						end
					end
					
					shouldBeWeld:Destroy()
					
				end
			end

		end
	end
end)

Probably super unoptimized, but I’m passing that problem on to you :joy:

1 Like

works as how i envisioned it, many thanks!! :]

1 Like

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