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

I need my script to loop untl I press play?

Asked by 4 years ago

Script:

local TweenService = game:GetService("TweenService")

local camera = game.Workspace.Camera

local cutsceneTime = 12

local tweenInfo = TweenInfo.new(
      cutsceneTime,
      Enum.EasingStyle.Sine,
      Enum.EasingDirection.Out,
      0,
      false,
      0
)

function tween(part1,part2)
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = part1.CFrame

    local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
    tween:Play()

    wait(cutsceneTime)

    camera.CameraType = Enum.CameraType.Custom
end

wait(0)

tween(game.Workspace.Test1,game.Workspace.Test2) 

1 answer

Log in to vote
1
Answered by
VAHMPIN 277 Moderation Voter
4 years ago
Edited 4 years ago
local TweenService = game:GetService("TweenService")
local Button = game.Players.LocalPlayer.PlayerGui -- path 
local PlayB = false
local sceneplaying = false
local camera = game.Workspace.Camera
local cutsceneTime = 12

Button.MouseButton1Down:connect(function()
    PlayB = true
end)

local tweenInfo = TweenInfo.new(
      cutsceneTime,
      Enum.EasingStyle.Sine,
      Enum.EasingDirection.Out,
      0,
      false,
      0
)

function tween(part1,part2)
    if sceneplayed == false then
    sceneplaying = true
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = part1.CFrame

    local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
    tween:Play()

    wait(cutsceneTime)

    camera.CameraType = Enum.CameraType.Custom
    end
    sceneplaying = false
end

wait(0)

repeat
  wait(12) -- // waits cutscene time 
    tween(game.Workspace.Test1,game.Workspace.Test2)
until PlayB == true -- until button is pressed
Ad

Answer this question