How do i make object position go higher by 2 and after that go lower by 2(but not teleport, moves)

Bruh i explained everything lmao, it’s just don’t works, i need it just go higher by 2 and lower by 2 z position

It’s just go up very much not by 2

Have you tried debugging the script to see what’s wrong? Devforum isn’t about giving all the answers, its a step by step solution to them.

You can also use TweenService | Roblox Creator Documentation for this.

image

local SpinObject = script.Parent
local x = 0
while x == 0  do
	print("first loop works good")
	SpinObject.Position += Vector3.new (0,0.1,0)
	task.wait(0.05)

	if SpinObject.Position == Vector3.new(-166.06, 2.929, 245.986) then
		x = 1
		end
		
	
	end
while x == 1  do
	print("second loop works good")
	SpinObject.Position -= Vector3.new (0,0.1,0)
	task.wait(0.05)
	if SpinObject.Position == Vector3.new(-166.06, 0.929, 245.986) then
		x = 0
	end
	end

x is still 0 i think or it’s don’t detect when x value changes

If you want it to up you just have to change the y value and keep everything at 0.

No i mean it must be like when z coordinate is 2 z cordinate lowers by 0.01 each 0.05 seconds to z coordinate 0

You should use tweenservice or lerp for that.

hmmmm can you exactly explain how to do that?

I’ve already sent the tweenservice link with it. Lerp is basically like tweenservice, but for cframes.

erm lol image

Is the part anchored? I also can’t help you if you don’t show me the code. :slight_smile:

Ofc anchored

local SpinObject = script.Parent
local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(
	2, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)

local tween = TweenService:Create(SpinObject, tweenInfo, {Position = Vector3.new(0, 2, 0)})

tween:Play()

Alr using ts (30 lettersssssssssssss)

Try un-anchoring it, play around with the part.

It’s doing strange things, now it’s spins and doing same thing as before

I think this is because of easing direction, what exactly directions are there?

Tween service, linear interpolation and body movers are your friends in this case.

I figured problem lol, but how do i make it slower it’s very fast

OMG It works thanks you guyssss!

1 Like