Could you show me your current code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local arrow = ReplicatedStorage:WaitForChild("Arrow")
local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local cloneStar = workspace:WaitForChild("Star")
print("Connected")
local level = player:WaitForChild("leaderstats").Level
print("Leaderstats found")
local play = true
print("on")
level.Value.Changed:Connect(function(newval)
print("on")
play = false
if cloneStar ~= nil then
if game.Workspace.Checkpoints:FindFirstChild(newval + 1) then
local ls = game.Workspace.Checkpoints:FindFirstChild(newval + 1)
if cloneStar.PrimaryPart then
local tweenInfo = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,1,false,0)
local NewPosition = {CFrame = ls.CFrame + Vector3.new(0,13.5,0)}
local tween = TweenService:Create(cloneStar.PrimaryPart, tweenInfo, NewPosition)
tween:Play()
print("Level changed to" ..newval)
tween.Completed:Wait()
play = true
print("Tween completed")
end
end
end
end)
local tweenInfo2 = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,-1,true,0 )
local FloatPosition = { Position = cloneStar.PrimaryPart.Position + Vector3.new(0,3,0)}
local tween2 = TweenService:Create(cloneStar.PrimaryPart, tweenInfo2, FloatPosition)
if play == false then
tween2:Pause()
print("Tween paused")
else
if play == true then
wait(0.5)
tween2:Play()
print ("Tween playing")
end
end
level.Changed
not level.Value.Changed
, Changed is already responsible for checking if the value changed
It worked but can you help me with one more thing?
The loops aren’t playing how I want them to play. I want the floating loop to keep playing until my level changes and when my level changes the float loop stops and the other loops plays and when that loop is finished playing the flosting loop restarts.
That is the basic rundown but what actually happens is that the floating loop is paused and the other loop plays and when the other loop is done and the floating loop starts back, the star comes back to the checkpoint it was on, that’s the error.
So how do I tweak my code to make it work??
I tried a while true do loop with this piece of code:
if play == false then
tween2:Pause()
print("Tween paused")
else
if play == true then
wait(0.5)
tween2:Play()
print ("Tween playing")
end
But it goes back to the old position, I need the floating tween to play in the new position.
It goes to the old position because the tween is not updated to make the star move to the new position, and that can be done by recreating tween2 where needed
Figured it out, thanks man you were a big help!