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

My if statement isn't working correctly?

Asked by 4 years ago

The problem is the close tween is never activated. No matter what the open tween is always the one to be activated when the RemoteEvent is fired. I'm trying to fix this. The OpenTween will work but the close won't, so it just turns 90 degrees every time it is clicked, eventually it does a full loop.

local TweenService = game:GetService("TweenService")
local Remote = game.ReplicatedStorage.Remotes.Gate

Remote.OnServerEvent:Connect(function(player,HingeLeft,HingeRight)

local Closed = true

if Closed then
        local Goal = {}
        Goal.CFrame = HingeLeft.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(-90), 0))

        local Tween = TweenService:Create(HingeLeft, TweenInfo.new(5, Enum.EasingStyle.Linear), Goal)

        Tween:Play()
HingeLeft.Parent.Parent.Sound:Play()
    else
        print('Close')
        local Goal = {}
        Goal.CFrame = HingeLeft.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(0), 0))

        local Tween = TweenService:Create(HingeLeft, TweenInfo.new(5), Goal)

        Tween:Play()
HingeLeft.Parent.Parent.Sound:Play()
    end
end)
0
It may be your tween system, put a print on every line and see where it stops printing Official_DuckyYT 55 — 4y
0
It was and wasn't at the same time. The tweens were fine it's just the order they were in. Ended up using two remotes rather than one. All is working now. TommyHArden 101 — 4y

Answer this question