Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"Else" conditional statement running anyways?????

Asked by 6 years ago

Okay, so this is really annoying, I am trying to make a game in under 24 hours and the "else" statement at line 40 is playing through the script even after the value of newapp is over 50, but the "if" part of it still plays also, resulting in an undesired tween. I am probably missing something very simple and stupid but i'm not able to find it! If someone could help me out that would be grand.

local TweenService = game:GetService("TweenService")
local applesauce = game.ServerStorage.Applesauce
local reset = false
local vat = game.Workspace.Vat.AppleSauceVat.Applesauce.Applesauce
local appcf = vat.CFrame
local stpos = vat.Parent.Startpos
local Emitter = game.Workspace.Vat.Pipe.Emitter.TurnOn
local x,y,z = vat.CFrame:toEulerAnglesXYZ()

applesauce.Changed:connect(function(newapp)
    wait()
    if newapp >= 50 then
        --TWEEN--
        local goal = {}
        goal.CFrame = stpos.CFrame

        local tweeninfo = TweenInfo.new(
            1,
            Enum.EasingStyle.Quad,
            Enum.EasingDirection.Out
        )

        local move = TweenService:Create(vat, tweeninfo, goal)
        move:Play()
        wait()
        --TWEEN--
        applesauce.Value = 0
        local playerfinder = game.Players
        for i, v in ipairs(playerfinder:GetChildren()) do --Finding Children of Players so we can add some stuff to them
            if v:FindFirstChild("leaderstats") then
                local leaderstat = v.leaderstats
                if leaderstat:FindFirstChild("Applesauce") then
                    local app = leaderstat.Applesauce
                    app.Value = app.Value + 1
                end
            else
                print("Selected Player has no leaderstat values or the script has failed to find a leaderstat folder.")
            end
        end
    else
        print("else")
        if newapp >= 50 then return end
        Emitter.Disabled = false
        local goal = {}
        goal.CFrame = vat.CFrame:toEulerAnglesXYZ() and vat.CFrame * CFrame.new(0,0.3,0)

        local tweeninformation = TweenInfo.new(
            1,
            Enum.EasingStyle.Quad,
            Enum.EasingDirection.Out
        )

        local move = TweenService:Create(vat, tweeninformation, goal)
        move:Play()
    end
end)

Answer this question