You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I wanna achieve when object position is 0,2,0 it’s go back like 0,0,0
What is the issue? Include screenshots / videos if possible!
I have no idea how i add that in loop
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tryed to use vector3 value, but idk how to add it to there
local SpinObject = script.Parent
while SpinObject.Position <= SpinObject.Position == Vector3.new(0,2.537,0) do
SpinObject.Position += Vector3.new (0,1,0)
task.wait(1)
end
local SpinObject = script.Parent
SpinObject:GetPropertyChangedSignal("Position"):Connect(function()
if SpinObject.Position.Y >= 2 then
SpinObject.Position += Vector3.new(0,-SpinObject.Position.Y,0)
end
end)
Try using the magnitude with the two vectors to detect the difference in an if statement.
Something like this:
local SpinObject = script.Parent
while SpinObject.Position.Magnitude == Vector3.new(0,2.537,0).Magnitude do
SpinObject.Position += Vector3.new (0,1,0)
task.wait(1)
end
local SpinObject = script.Parent
SpinObject:GetPropertyChangedSignal("Position"):Connect(function()
if SpinObject.Position.Y <= 2 then
SpinObject.Position += Vector3.new (0,1,0)
task.wait(1)
end
end)
SpinObject:GetPropertyChangedSignal("Position"):Connect(function()
if SpinObject.Position.Y >= 2 then
SpinObject.Position -= Vector3.new (0,1,0)
task.wait(1)
end
end)