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)
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
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.
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