#tween2 doesnt creating

1 messages · Page 1 of 1 (latest)

swift imp
#
function Change(power,hit)
    local potion = script.Parent.Potion
    local pos = script.Parent.Potion.Position
    potion.AnchorPoint = Vector2.new(pos.X,pos.Y)
        if targetSet == false and Parts[hit.Name.."X2"] ~= nil then
            print("Two-step")
            local targetPosition = UDim2.new(pos.X.Scale,pos.X.Offset+Parts[hit.Name.."X"],pos.Y.Scale,pos.Y.Offset+Parts[hit.Name.."Y"])
            local targetPosition2 = UDim2.new(pos.X.Scale,pos.X.Offset+Parts[hit.Name.."X"]+Parts[hit.Name.."X2"],pos.Y.Scale,pos.Y.Offset+Parts[hit.Name.."Y"]+Parts[hit.Name.."Y2"])
            targetSet = true
            
            local tweenInfo = TweenInfo.new(1.25,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
            tween = TweenService:Create(potion, tweenInfo, {Position = targetPosition})
            print("Tween initialized:", tween)
            tween2 = TweenService:Create(potion, tweenInfo, {Position = targetPosition2})
            print("Tween2 initialized:", tween2)
        elseif targetSet == false then
            print("One-step")
            local targetPosition = UDim2.new(pos.X.Scale,pos.X.Offset+Parts[hit.Name.."X"],pos.Y.Scale,pos.Y.Offset+Parts[hit.Name.."Y"])
            targetSet = true
            local tweenInfo = TweenInfo.new(2.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
            tween = TweenService:Create(potion, tweenInfo, {Position = targetPosition})
        end
end

im only trying understand tween so maybe here is dumb question, print("Tween initialized:", tween) is printing but tween2 is always nil and not printing at other stroke

#
if tween ~= nil then
  tween:Play()
  tween.Completed:Connect(function()
    tween2:Play()
  end)
end

at this part tween2 is always nil

#

when tween isnt

broken tulip
#

add "if"

swift imp
#

if tween2 ~= nil you mean

#

then it wont help

broken tulip
#

have u tried it?

swift imp
#

tween2 wont play but no errors

#

I need when tween ended tween2 play

broken tulip
#

have u gotten an error by something that you thought would change tween2

#

thought*

swift imp
#

but it should play after tween2 played

broken tulip
#

i don t really see the problem in ur script tho

celest cliff
#
            tween = TweenService:Create(potion, tweenInfo, {Position = targetPosition})
            print("Tween initialized:", tween)
            tween2 = TweenService:Create(potion, tweenInfo, {Position = targetPosition2})
            print("Tween2 initialized:", tween2)``` can you show this in output window?
broken tulip
swift imp
swift imp
celest cliff
#

show full code thonkoof

swift imp
celest cliff
#

in-game console differs from the output window. always use the studio output window.

celest cliff
# swift imp

what is script.Parent.Potion? is this a localscript or server script? where is it?

celest cliff
# swift imp

there are so many things to unpack in there, and it gets worse the more i read into it agony

swift imp
#

so detector is a local script

celest cliff
#

at this point i think just add a breakpoint

#

breakpoints are like prints but more involved

swift imp
celest cliff
#

and practice

#

put breakpoint, open watch window etc

swift imp
#

but how does it can help me

celest cliff
#

step through until unexpected etc

celest cliff
#

if breakpoint doesnt break then move it to earlier in the code

#

debugging is key essential coding skill

#

you either learn it or hire someone

swift imp
celest cliff
swift imp
#

im just stuck, tween2 literally doesnt initialize for no reason

swift imp
celest cliff
#

you s1 aren't you? or are you? 🧐

swift imp
celest cliff
# swift imp i dont see too

i dont see obvious error either, by your descriptions the code stops half way through silently, or maybe you just describing it poorly. hard to say. put breakpoints around the problem area and try it from there Thumbs

#

like if you have a print then 2 lines later it stop print silently, add a breakpoint, review your watch variables window and step from there 👍

swift imp
swift imp
celest cliff
swift imp
swift imp
#

I cant figure it out

#

2 hours of trying and nothing