Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my water shoot up above a tool when a tool touches it?

Asked by 5 years ago

I have no idea why this is happening. Everything about the script works fine, just everytime a tool touches the water, the water shoots up. Here it is:

local brick = script.Parent
brick.Position=Vector3.new(-35.5, 1.301, -12)

waveSpeed = 0.1
waveHeight = 0.005

while wait(0.1) do 

for I=1,20 do 
brick.Position=brick.Position+Vector3.new(0,-waveHeight,0) --Lower water
wait(waveSpeed)
end

wait(1)

for I=1,20 do 
brick.Position=brick.Position+Vector3.new(0,waveHeight,0) --Raise Water
wait(waveSpeed) 
end 

brick.Position=Vector3.new(-35.5, 1.301, -12)

wait(1)

end 
0
there is no touch function in this Warfaresh0t 414 — 5y

1 answer

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
5 years ago

This is because of Roblox's position physics caused with Anchored parts getting moved from it's position.

If you want to keep it from getting pushed to the top of parts that collide with it use CFrame to tween it up and down. Someone else might be able to elaborate on why CFrame works or just look it up on RobloxDev.

Here's how you would convert to using the CFrame of the part:

brick.CFrame = brick.CFrame + Vector3.new(0, waveHeight, 0)

I just copied and edited line 17 but you would do the same to lines 2, 10, and 21.

Ad

Answer this question