Tween gradually decreases Y Value

Hello! I am trying to make random Position every second and for some reason the Y Position of the AlienShip decreases after it loops 1 time. I can’t tell why its happening. It’s supposed to stay always 238 but in the screenshot, it always goes down. The Union is has no collision on. Anyone got a solution why?

function AlienAttackEvent()    
	local Alieninfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Linear
	)
	local CloneAlien = ServerStorage.Events.AlienAttack:Clone()
	CloneAlien.Parent = Map.Events
	local Time = 50
	while Time >= 1 do
		local RandX = math.random(-317, -51)
		local Y = 238
		local RandZ = math.random( -84, 158)
		local spikepos = Vector3.new(RandX, Y, RandZ)
		local AlienTween = TweenService:Create(CloneAlien.AlienShip, Alieninfo, {Position = spikepos})
		print(spikepos.Y)
		print(CloneAlien.AlienShip.Position.Y)
		AlienTween:Play()
		Time -= 1
		task.wait(1)
		if Time == 1 then
			CloneAlien:Destroy()
			break
		end
	end
end

This is what the Output shows:

Is the changing of its position visible when you playtest the game?

Yea, the Position of the AlienShip is set to the 2nd prints and then tweens to the 238, and after a time it jitters because of that

is it unanchored?
charsssssssssssssssssssss

Omg. I missed that. I swear I turned it on while checking. Ugh… Well thank you. Have a good day

les go i speedrunned it
woooooooooooo
you too

Assuming your model / part is correct :

you could add a completed event to wait for the previous tween.

here is how

function AlienAttackEvent()    
	local Alieninfo = TweenInfo.new(
		1,
		Enum.EasingStyle.Linear
	)
	local CloneAlien = ServerStorage.Events.AlienAttack:Clone()
	CloneAlien.Parent = Map.Events
	local Time = 50
	while Time >= 1 do
		local RandX = math.random(-317, -51)
		local Y = 238
		local RandZ = math.random( -84, 158)
		local spikepos = Vector3.new(RandX, Y, RandZ)
		local AlienTween = TweenService:Create(CloneAlien.AlienShip, Alieninfo, {Position = spikepos})
		print(spikepos.Y)
		print(CloneAlien.AlienShip.Position.Y)
		AlienTween:Play()
		AlienTween.Completed:Wait() -- Wait for the current tween to finish
		Time -= 1
		task.wait(1)
		if Time == 1 then
			CloneAlien:Destroy()
			break
		end
	end
end

World Record :call_me_hand:
chaaaaaaaaaaaaaars

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.