I am making a flood survival game. I want to do something that when the flood water(which is a part) touches a welded part, the weld in it is destroyed so if a building is welded together it will fall down as the water touches it.
But for some reason the touched event is not firing. I have tried putting in some prints but it is not printing anything in the output and also no errors are there. I haven’t tried any solutions yet because I can’t think of any. Searching on the internet also didn’t help.
Any help is appreciated!
Here is the script which is located inside the ‘water part’.
local flood = game.ReplicatedStorage.Values.Flood
flood.Changed:Connect(function()
script.Parent.Transparency = 0.3
script.Parent.Partsoo.Transparency = 0.3
while not flood.Value == false do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,-1)
wait(0.01)
end
script.Parent.Position = Vector3.new(-926.5, -21.25, 483.375)
script.Parent.Partsoo.Position = Vector3.new(-926.75, -21.25, 168.75)
script.Parent.Size = Vector3.new(339.5, 9, 616.25)
script.Parent.Transparency = 0
script.Parent.Partsoo.Transparency = 0
end)
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if plr.Character.Humanoid.Health ~= 0 then
plr.Character.Humanoid.Health = 0
end
else
for _,v in pairs(hit:GetChildren()) do
if v:IsA("Weld") or v:IsA("ManualWeld") then
v:Destroy()
end
end
end
end)