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

While True Loop keep going after the playbutton is pressed?

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?

1 comment

0

im not understanding this??

1 answer

✓ Accepted answer

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

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