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

My tween doesnt work, however works when the player sits down for a second time. Any help?

Asked by 3 years ago
Edited 3 years ago

Im trying to get a frame to tween its "BackgroundTransparency" properties but it only works after i activate it on the second try in game. Ive also put a print after the tweens and it still prints it. Anyone know why?

local PlayerSitting
local campart = script.Parent.Parent.Parent.Parent.CamPart
local seat = script.Parent
local tweenservice = game:GetService("TweenService")
local tween3
local tween4
script.Parent:GetPropertyChangedSignal("Occupant"):Connect(function()
    if script.Parent.Occupant == nil then -- Player Jumped Out
        if PlayerSitting ~= nil then -- Player Is In Game (Did not Leave Game)
            local PlayerUI = PlayerSitting:WaitForChild("PlayerGui")
            local NeededUI = PlayerUI:FindFirstChild("PCGUI") -- Change this To Your GUI Name
            NeededUI.Enabled = false
            tween3:Play()
            tween4:Play()

            PlayerSitting = nil -- Set The Var to nil
        end
    else -- Someone Sat Down
        PlayerSitting = game.Players:GetPlayerFromCharacter(script.Parent.Occupant.Parent)
        game.Workspace.Events.Camera:FireClient(PlayerSitting,campart,seat)
        game.Workspace.Events.CameraReturn.OnServerEvent:Connect(function()
            local PlayerUI = PlayerSitting:WaitForChild("PlayerGui")
            local NeededUI = PlayerUI:FindFirstChild("PCGUI") -- Change this To Your GUI Name
            NeededUI.Enabled = true

            local tween = tweenservice:Create(campart.Parent.Screen.Main, TweenInfo.new(1),{
                Color = Color3.fromRGB(255,255,255)
            })

            local tween2 = tweenservice:Create(NeededUI.PCGUI, TweenInfo.new(1),{
                BackgroundTransparency = 0
            })

            tween3 = tweenservice:Create(campart.Parent.Screen.Main, TweenInfo.new(1),{
                Color = Color3.fromRGB(27, 42, 53)
            })

            tween4 = tweenservice:Create(NeededUI.PCGUI, TweenInfo.new(1),{
                BackgroundTransparency = 1
            })

            tween2:Play()
            tween:Play()
            print("yes")
        end)
    end
end)

Answer this question