Hey there, this is my first post on the forums.
I am currently wanting one of my main menu play buttons to “break” a while do loop for a cut scene I have in my game once it is clicked. However, I am having trouble with understanding how to do that as I am novice in scripting.
One local script is responsible for the cut scene (a camera which rotates around the map) and the other is the play button (once pressed it removes the main menu GUI and stops the cut scene).
One option I have tried is adding an if statement which checks if the frame is disabled in order to break the loop.
Edit*: The cameras 4 cameras I have are named: Test1, Test2, Test3 and Test4.
Here is the local script for the cut scene:
local TweenService = game:GetService("TweenService") --Getting tweenservice
local camera = game.Workspace.Camera --variable for camera
local cutsceneTime = 20 --length of cutscene
local frame = game.StarterGui.MainMenu
local tweenInfo = TweenInfo.new(
cutsceneTime, --time
Enum.EasingStyle.Linear, --style
Enum.EasingDirection.Out, --direction
0, -- repeat
false, -- reverse
0 -- delay
)
function tween(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable --allows to edit camera
camera.CFrame = part1.CFrame --position and rotation, looks from the position of part 1
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
wait(cutsceneTime)
camera.CameraType = Enum.CameraType.Custom
end
while true do
wait()
tween(game.Workspace.Test1,game.Workspace.Test2)
tween(game.Workspace.Test2,game.Workspace.Test3)
tween(game.Workspace.Test3,game.Workspace.Test4)
tween(game.Workspace.Test4,game.Workspace.Test1)
if frame.Enabled == false then
break
end
end
And here is the local script for the button:
local button = script.Parent
local frame = script.Parent.Parent.Parent.Parent.Parent.MainMenu
local player = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
frame.Enabled = false
end)
Here is a screencap of my studio:
Kind regards,
ricefield_man