Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i fix this tween/loading screen error ? please help me ?




game.ReplicatedStorage.Camera.OnClientEvent:Connect(function()
    local plr = game.Players.LocalPlayer
    local camera = game.Workspace.CurrentCamera
    camera.CameraType = 'Scriptable'
    camera.CFrame = game.Workspace.CameraTool1.CFrame
    local tween = game:GetService('TweenService'):Create(camera, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0), {CFrame = game.Workspace.CameraTool2.CFrame})
    local tween2 = game:GetService('TweenService'):Create(camera, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0), {CFrame = game.Workspace.CameraTool3.CFrame})
    local tween3 = game:GetService('TweenService'):Create(camera, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0), {CFrame = game.Workspace.CameraTool4.CFrame})
    tween:Play()
    wait(6)
    tween2:Play()    
    wait(6)
    tween3:Play()
    plr.PlayerGui.LoadingGui.PlayButton.MouseButton1Down:Connect(function()
        tween:Pause()
        tween2:Pause()
        tween3:Pause()
        camera.CameraType = 'Custom'
        game.StarterGui:SetCore('SendNotification', {Title = 'Game Message', Text = 'Enjoy the game :)'})
        plr.PlayerGui.LoadingGui.PlayButton.Visible = false
        plr.PlayerGui.LoadingGui.CreditsButton.Visible = false
        plr.PlayerGui.LoadingGui.Frame.Visible = false
    end)
    
end)

Why doesnt spawn me in the game when i press play, only after im in the process of the last tween it spawns me when i press.

1 answer

--[[ the waits pauses your whole script so you cant press it until tween3 starts
    tween:Play()
    wait(6)
    tween2:Play()    
    wait(6)
    tween3:Play()
]]


-- you could do something like this (taken out of your script, the part I added and one line above and below it)

    local tween3 = game:GetService('TweenService'):Create(camera, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0), {CFrame = game.Workspace.CameraTool4.CFrame})

-- part that I changed from your script
local startTweens = coroutine.wrap(function()
	    tween:Play()
    wait(6)
    tween2:Play()    
    wait(6)
    tween3:Play()
end)
startTweens()


    plr.PlayerGui.LoadingGui.PlayButton.MouseButton1Down:Connect(function()

This discussion is preserved as it was. New answers, comments, and votes are closed.