When Text Button Clicked, plays cutscene

  1. What do you want to achieve? If a Text button is clicked it will play a cutscene.

  2. What is the issue? The cutscene shouldn’t start until a text button is clicked.

  3. What solutions have you tried so far? I have tried many solutions but none have worked so far.

Here is my current cutscene script. I don’t want the cutscene to start before the text button is clicked I’m not sure how to add this.

wait(0.1)	
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart.CFrame
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
	Cutscene:Play()
	wait(Duration)
end

wait(2)

local function Cutscene()
	MoveCamera(game.Workspace.CameraA, game.Workspace.CameraA, 3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
	MoveCamera(game.Workspace.CameraA, game.Workspace.CameraB, 5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	MoveCamera(game.Workspace.CameraB, game.Workspace.CameraC, 6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	wait(.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
end

Cutscene()

If i understood right, this should work:

TextButton.MouseButton1Down:Connect(Cutscene)

Didn’t work when I added it to the script nor did it give me an error code :confused:

Can you send the code that you just tried?

This is how I added it into the script.

game.StarterGui.UIScene1.ImageLabel.Start.PlayButton.MouseButton1Down:Connect(CutScene)
wait(1)
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart.CFrame
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
	Cutscene:Play()
	wait(Duration)
end

wait(2)

local function Cutscene()
	MoveCamera(game.Workspace.CameraA, game.Workspace.CameraA, 3, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
	MoveCamera(game.Workspace.CameraA, game.Workspace.CameraB, 5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	MoveCamera(game.Workspace.CameraB, game.Workspace.CameraC, 6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	wait(.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
end

Cutscene()
1 Like

Replace Cutscene() at the bottom with:
game.StarterGui.UIScene1.ImageLabel.Start.PlayButton.MouseButton1Down:Connect(Cutscene)

Also remove the first line, that is hella wrong.
Remove wait(2), there is no point to use wait.

Try making 2 remote events in replicated storage named start and finish. Try this code (note I am making the code on phone so you may have to revise it a little.)

Start.OnClientEvent:Connect(function()
    — code for your cutscene
  Finish:FireClient()
end)

This could be wrong because I don’t know much about remote events.

Tried it, still not working do you think they’re any other solutions?

The script should work you just forgot a little something

game.StarterGui.UIScene1.ImageLabel.Start.PlayButton.MouseButton1Down:Connect(CutScene)

That is wrong ^
The button wont be in startergui but in playergui

local Players = game.Players
local Player = Players.LocalPlayer

Player.PlayerGui.UIScene1.ImageLabel.Start.PlayButton.MouseButton1Down:Connect(CutScene)

Make sure the script is in a localscript
also
Next time put the script inside the button, so you can just do

script.Parent.MouseButton1Down:Connect()

Where is the PlayerGui Folder?
image