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

Wait() interrupting my scripts and not making them continue?

Asked by 3 years ago

I noticed that whenever I add a wait() function to the scripts I am making, they stop once the wait function arrives, even though the times is a very little interval of time... could anyone help me?

Examples:

local original = script.Parent.Parent
local up = script.Parent.Parent.Parent.Arrival

script.Parent.PromptButtonHoldEnded:Connect(function(plr)
    if plr.Team ~= game.Teams.CD then
        local goalData = {CFrame = up.CFrame}

        local tween = game.TweenService:Create(script.Parent.Parent,TweenInfo.new(4),goalData)
        tween:Play()

        wait(4) --Stops right here!!

        goalData = {CFrame = original.CFrame}
        local tween = game.TweenService:Create(script.Parent.Parent,TweenInfo.new(4),goalData)
        tween:Play()
    end
end)
script.Parent.MouseButton1Down:Connect(function()
    local player = game.Players.LocalPlayer
    local bname = "CD"

    player.Character.Humanoid.Health = 0

    if player.Team == game.Teams.Choosing then
        game.ReplicatedStorage.RemoteEvents.Teams:FireServer(bname)
    end

    script.Click:Play()

        wait(5)

    local CurrentCamera = workspace.CurrentCamera
    CurrentCamera.CameraType = Enum.CameraType.Custom
    CurrentCamera.CameraSubject = game.Players.LocalPlayer

    script.Parent.Parent.Parent.Enabled = false
    game.Workspace.Musics.Menu:Stop()
    game.Workspace.Musics.Background:Play()
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Why do you want the script to wait? Try add print("ok") directly after the wait and leave it for 10 seconds to run and see if it comes up? If the thing prints the issue is probably on your tween declaration (is it supposed to be "new(4)" or "new[4]" ? If it doesn't print then try removing the wait and seeing if it prints?

0
Didn't save my formatting sorry AlexTheCreator 461 — 3y
Ad

Answer this question