Click play to end cutscene and spawn in

I already have it so when you join you are presented with the title and a play button Along with that there are different camera points around the map so the camera moves around. But I want it so when before you click play your player does not spawn. I also need help scripting it so when you click play the camera switched from moving around the map to the classic Roblox camera view; As well with removing the title and play button from the players screen. Here is what I have so far:


image

2 Likes

Can you please provide your code within the text format in the code blocks?
So I can rewrite it.

1 Like

What do you mean by code blocks?

image

local hi : string = "hello"

What is this you are showing me?

Thats a code block, copy the code of your cutscene and paste it in the blocks
So it will be easier for me to edit it.


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 = TweenServive: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)
tween(game.Workspace.Test2,game.Workspace.Test3)
tween(game.Workspace.Test3,game.Workspace.Test4)
tween(game.Workspace.Test4,game.Workspace.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)
tween(game.Workspace.Test14,game.Workspace.Test1)
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.Test5)
tween(game.Workspace.Test5,game.Workspace.Test6)
tween(game.Workspace.Test6,game.Workspace.Test7)
tween(game.Workspace.Test7,game.Workspace.Test8)
tween(game.Workspace.Test8,game.Workspace.Test9)
tween(game.Workspace.Test9,game.Workspace.Test10)
tween(game.Workspace.Test10,game.Workspace.Test11)
tween(game.Workspace.Test11,game.Workspace.Test12)
tween(game.Workspace.Test12,game.Workspace.Test13)
tween(game.Workspace.Test13,game.Workspace.Test14)```

Okay give me a moment, I’ll provide you the fixed code with the explanation.

2 Likes

Are you going to add the player does not spawn until they click play and when they click play it switches to the players camera view?

Yep, I got what you mean.
Like first camera moves to different points they are called as Test{partNumber}
Whenever player clicks the play button that background camera animation stops and camera focus on the player.

2 Likes

I’ve made a new script which does everything you asked for.

  • Plays cutscene until player clicks play button
  • Once menu is invisible, spawns the character (uses LoadCharacter function to load the character)
ServerScript inside ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Event = ReplicatedStorage:FindFirstChild("spawnPlayer")
if not Event then
	local newEvent = Instance.new("RemoteEvent")
	newEvent.Name = "spawnPlayer"
	newEvent.Parent = ReplicatedStorage
	Event = newEvent
end

Event.OnServerEvent:Connect(function(Player)
	if Player:GetAttribute("loadedMenu") == false then
		Player:SetAttribute("loadedMenu", true)
		Player:LoadCharacter()
	end
end)

Players.PlayerAdded:Connect(function(Player) 
	Player:SetAttribute("loadedMenu", false)
	Player.CharacterAdded:Connect(function(Char)
		if Player:GetAttribute("loadedMenu") == false then
			Char:Destroy()
		end
	end)
end)
(EDIT#1) LocalScript inside your play button
local TweenService = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local camera = game.Workspace.Camera

StarterGui:SetCore("ResetButtonCallback", false)

local setting = {}
setting.cutsceneTime = 5;
setting.cutscenePrefix = "Test";
setting.tweenInfo = TweenInfo.new(
	setting.cutsceneTime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
);
setting.TweenObjectsLocation = game.Workspace;
setting.myMethod = true; -- By using my method there will be a white flash tween which will tween a new frame to fully visible, change menu frame visible to false and then load to player

local inMenu = true
local menuVisible = true
local scenePlaying = false
local spawnCharacterEvent = nil

function spawnPlr()
	menuVisible = false -- DO NOT DELETE THIS LINE! put it after the line where you change the menu frame visible to false
	StarterGui:SetCore("ResetButtonCallback", true) -- Keep this line with the line above it
	local spawnCharacterEventFind = ReplicatedStorage:FindFirstChild("spawnPlayer")
	if spawnCharacterEventFind then
		spawnCharacterEventFind.Parent = nil
		spawnCharacterEventFind:FireServer()
		spawnCharacterEvent = spawnCharacterEventFind
	else
		if spawnCharacterEvent then
			spawnCharacterEvent:FireServer()
		end
	end
end

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

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

	local finishFunc
	finishFunc = tween.Completed:Connect(function()
		scenePlaying = false
		finishFunc:Disconnect()
		finishFunc = nil
	end)
	repeat task.wait() until scenePlaying == false or inMenu == false
	if inMenu == false then
		repeat task.wait() until menuVisible == false
		camera.CameraType = Enum.CameraType.Custom
	end
end

task.wait(2)

local spawnCharacterEventFind = ReplicatedStorage:FindFirstChild("spawnPlayer")
if spawnCharacterEventFind then
	spawnCharacterEventFind.Parent = nil
	spawnCharacterEvent = spawnCharacterEventFind
end

local ObjectsToTween = {}
function addTweenObject(index, obj)
	ObjectsToTween[index] = obj
end

for i,v in pairs(setting.TweenObjectsLocation:GetChildren()) do
	if v.Name:lower():find(setting.cutscenePrefix:lower()) then
		if #v.Name > #(setting.cutscenePrefix) then
			local number = v.Name:sub(#(setting.cutscenePrefix) + 1, #v.Name)
			if tonumber(number) ~= nil then
				addTweenObject(tonumber(number), v)
			end
		end
	end
end

function StartTween()
	for i,v in pairs(ObjectsToTween) do
		if not inMenu then break end
		if i < #ObjectsToTween then
			tween(v, ObjectsToTween[i + 1])
		end
	end
end

coroutine.wrap(function()
	while inMenu do
		StartTween()
		task.wait()
	end
end)()

local function PlayButton()
	if not inMenu then return end
	inMenu = false
	if setting.myMethod then
		local GUI = script.Parent:FindFirstAncestorOfClass("ScreenGui")
		if GUI then
			local FlashFrame = Instance.new("Frame")
			FlashFrame.Name = "FlashFrame"
			FlashFrame.AnchorPoint = Vector2.new(0.5, 0.5)
			FlashFrame.Position = UDim2.new(0.5, 0, 0.5, 0)
			FlashFrame.Size = UDim2.new(1, 0, 1, 0)
			FlashFrame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
			FlashFrame.BorderSizePixel = 0
			FlashFrame.BackgroundTransparency = 1
			FlashFrame.ZIndex = 999999999
			FlashFrame.Parent = GUI
			local Visibility = true
			local Duration = 2
			local function createNewTween(visible)
				Visibility = visible
				local newTween = TweenService:Create(
					FlashFrame, 
					TweenInfo.new(
						Duration,
						Enum.EasingStyle.Sine,
						Enum.EasingDirection.Out
					),
					{
						BackgroundTransparency = Visibility == true and 0 or 1
					}
				)
				return newTween
			end
			local TweenObj = createNewTween(true)
			TweenObj:Play()
			TweenObj.Completed:Wait()
			TweenObj = createNewTween(false)

			local MenuFrame = nil -- Must specify
			if MenuFrame ~= nil then
				MenuFrame.Visible = false
			else
				MenuFrame = GUI
				GUI.Enabled = false
			end
			spawnPlr()

			TweenObj:Play()
			TweenObj.Completed:Wait()
			FlashFrame:Destroy()
			-- You can put more of your code for additional stuff if you wish

		end
		return
	end
	-- If you don't want to use my method (you can set using my method to false in the settings table, if you want), just put your own code here which changes the menu visible and other things


	spawnPlr() -- DO NOT DELETE THIS LINE! put it after the line where you change the menu frame visible to false
end

script.Parent.MouseButton1Click:Connect(PlayButton)

A few things to keep note of:

  • You should see a settings table inside of the LocalScript. All the settings are there and you can change them if you want.
  • There is a “myMethod” setting and what this does is uses my method to make the title and play disappear (or menu), but you will have to specifiy what your menu frame is, in the MenuFrame variable, or your own variable (if you’re not using my method), or else it will not work!
  • I also suggest going through every line of the code and looking for the notes (notes look like this -- hello), I’ve created the notes so you know how to properly configure the script and understand it without making an error.

Also, whenever someone solves your topic, make sure to click the solution button to give them credit! There are others on here who might be having the same issue that you were having, so doing this would help them find the solution.

5 Likes

Do I need to get rid of my current script or do I keep it?

And is a serverscript just a script?

You can disable it temporarily, just in case my scripts don’t work, but then add the LocalScript I provided into the play button and another to ServerScriptService which will be the ServerScript. Also, yes, ServerScript is a normal Script.

Will this new script keep the cutscene looping?

Yes, it will keep the cutscene looping and prevent the player from spawning in until they click the play button.

1 Like

Do I need to change anything or test it right off the bat?

Yeah, you need to change stuff… just read through the post I just made and there will be instructions for proper setup.

1 Like

What do you mean by this?

It will just make a new frame on the screen that will tween in, close out of the menu, and then the frame will disappear. The Player character will load in after that