Cutscene Skip Button

Hey there!
I have a local script that plays a cutscene every time a player joins, but I haven’t been able to get the cutscene to skip. I feel like it would use a remote event, but I’m not sure how, since the cut scene is handled in a local script, as I said. The script is in a text button, in a screengui in startergui. Here’s the code:

local TweenService = game:GetService("TweenService")


local camera = workspace.Camera


local sound = script.Sound


function tween (part1, part2, cutsceneTime)

	local TweenInfo = TweenInfo.new(
		cutsceneTime,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
	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(2)

sound:Play()
tween(game.Workspace.Camera1, game.Workspace.Camera2, 5)
camera.CameraType = Enum.CameraType.Fixed
wait(30)
camera.CameraType = Enum.CameraType.Scriptable
sound:Stop()
tween(game.Workspace.Camera2, game.Workspace.Camera3, 5)
camera.CameraType = Enum.CameraType.Fixed
wait(10)
camera.CameraType = Enum.CameraType.Custom

How would I modify this to make it skippable?

3 Likes

When the button is clicked, just set the camera back to the default and make Script.Disabled = true.

I’m thinking that you can write something like this:

local skipped = false
skipButton.MouseButton1Down:Connect(function()
    skipped = true
    --set the camera settings to the default settings here
end)

Then, inside the tween function, you can write that the tween will only play when skipped is false. You can do this by using an if statement.

I don’t believe that disabling scripts while the game is running is very practical.

I don’t see why disabling a script isn’t practical, especially if it’s a cutscene which won’t be running after anyways.

I’ve heard that it’s bad practice. I’ve also heard that a script can’t disable itself. It must be disabled by a different script that isn’t the child of the script being disabled.
I’ve tried disabling scripts and it just doesn’t work well, especially since it can’t disable itself.

A script can disable itself. I use that a lot in many scripts I do. However, a local script, even if disabled, won’t do anything unless a remote event is used to tell the server.

1 Like

Yeah, nevermind, you’re probably right. I don’t know how efficiently the current thread is stopped when disabling a script.

I think with your method, if there is a tween currently running, then it wouldn’t skip right away.

Right. I actually just encountered that. I got it to work, but I’m going to make sure it doesn’t disable the script for all players, even those who join after it’s clicked. It shouldn’t, but better safe than sorry.

1 Like

Use corountine to do this, you could disable the script however it isn’t good practice as @dodle120 said.

Here is a post to help with understanding corountine

corountine.yield() will help pause the function of your cutscene and you should be able to fix the player’s camera after you yield the cutscene function.

3 Likes