I want to make a ocean that rises and destroys a house by unanchoring the parts of the house.
The issue is that when the ocean rises, the parts of the house don’t unanchor and don’t even show up in the output console.
I tried making these scripts and looking for solutions but nothing worked and I don’t know why.
Script in ServerScriptService that moves the ocean up and back down:
wait(15)
print("go")
for i=1, 550, 1 do
wait(0.01)
game.Workspace.Ocean.Position = game.Workspace.Ocean.Position + Vector3.new(0, 0.1, 0)
end
wait(10)
game.Workspace.Ocean.Position = Vector3.new(0, -90, 0)
Script in the ocean part that check if it touched another part:
script.Parent.Touched:Connect(function(part)
print(part)
if part.Name == "HousePart" then
part.Anchored = false
end
end)
(I don’t know if it has to do with the actual properties of the blocks but if it does, the ocean is anchored, has CanCollide off, and has CanTouch on. The house parts are anchored, have CanCollide on, and have CanTouch on.)
If It doesn’t print it means the OnTouch event isn’t being fired. You can debug further or check script to see if its disabled I recommend putting a print outside of the OnTouch event
print("Connecting Ontouch event to script.Parent")
script.Parent.Touched:Connect(function(part)
If that^ doesn’t print it’s likely the script is disabled or yielding before the you connect the event which would prevent the code from working as intended
There is no typo and even if there was, it should still print the part before it does the if statement. If you have discord, I can actually show you what is going on in game. Me and my friend have been trying to solve this for like two days lol.
Anchored parts don’t register touches with other anchored parts, especially when manually moving it. Overall, using .Touched tends to vary pretty heavily, but if you want to use it, you’d probably have to make some the house unanchored. A solution you could use would be BasePart:GetTouchingParts(), but since it doesn’t work with CanCollide = false parts, I recommend you look at this post: