local buttonPressed = false script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not buttonPressed then buttonPressed = true for i = 16.3, 15.9, -0.01 do script.Parent.Position = Vector3.new(3.5,i,10) end script.Parent.BrickColor = BrickColor.new("Really red") buttonPressed = false end end)
I want to make a block go from 16.3 to 15.9 in the Y axis, and instead of going down it goes up. Can't understand why.
Position works weirdly. Since position detects collisions with other parts, the position changes to where it won't collide with anything. So your code is correct except you have to change 'Position' to 'CFrame'. This is how the code should be.
local buttonPressed = false script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not buttonPressed then buttonPressed = true for i = 16.3, 15.9, -0.01 do script.Parent.CFrame = CFrame.new(3.5,i,10) -- Here's the Change. end script.Parent.BrickColor = BrickColor.new("Really red") buttonPressed = false end end)
While looking I've noticed you are using .Position =
That is very dangereous as it may move your part/model to a position different than expected, for example...
Imagine your part is inside a house... It's on the wall... It will move up or down. Change it to .CFrame = CFrame.new(...