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

While True Loop keep going after the playbutton is pressed?

Asked by 3 years ago
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local PlayButton = script.Parent.PLAY

repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable

PlayButton.MouseButton1Click:Connect(function()
    PlayButton:Destroy()
    wait(2.5)
    Camera.CameraType = Enum.CameraType.Custom
end)

while true do
Camera.CFrame = workspace.CameraPart.CFrame
    wait(4)
    Camera.CFrame = workspace.CameraPart2.CFrame
    wait(4)
end

after i click playbutton it still does not end the while true loop how would i fix this.

this is affecting my players camera.

can someone tell me how to end the while true loop?

0
im not understanding this?? piximentility 37 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I think this might work, if not maybe try putting the MouseButton1Click:Connect inside the while loop and use break.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local PlayButton = script.Parent.PLAY
local click = true
repeat wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable

PlayButton.MouseButton1Click:Connect(function()
    click = false
    PlayButton:Destroy()
    wait(2.5)
    Camera.CameraType = Enum.CameraType.Custom
end)

while click do
Camera.CFrame = workspace.CameraPart.CFrame
    wait(4)
    Camera.CFrame = workspace.CameraPart2.CFrame
    wait(4)
end
Ad

Answer this question