What is the best way to make a Cutscene Toggle button?

What I’m Attempting

I’m attempting to make a Cutscene toggle button. What I mean by this is…
When you click a button to disable cutscenes… it stays disabled on a respawn or character added.

Issues

No matter what I try, I can never seem to keep the cutscenes disabled after a respawn.

Solutions

I’ve tried going through the client with a PlayerGui Removal.
I’ve tried using a BoolValue.
I’m completely lost.

Photos

This is where cutscenes are located and the folder they are duplicated to, this is the folder to play the said cutscenes.


This is me using the ROBLOX Studio Client to remove the folder, as you see this part works.

This is when I respawn in the same game. The folder returns. I know why it returns, it’s because it’s in StarterGui but I don’t know of any other way around this.

The Scripts

Main Cutscene Script Player, the script that plays the cutscenes.
--Made By MillerrIAm
-------------------Variables------------------
Cutscene = game:GetService("ServerStorage").Cutscenes
FixCam = game:GetService("ServerStorage").ExtraItems
Event = game.ReplicatedStorage.GUIEvents.CutscenePlayer
Enabled = false
------------------Main Script------------------
Event.OnServerEvent:Connect(function(plr,Play,argument)
	if game.StarterGui:FindFirstChild("Cutscenes") then
		local args = {argument}
		if Play == "On" then
			if not plr.PlayerGui.Cutscenes:FindFirstChild(""..argument) then
				for i,x in pairs (game.Players:GetPlayers()) do
					Cutscene:FindFirstChild(""..argument):Clone().Parent = x.PlayerGui.Cutscenes
					x.PlayerGui.Cutscenes:FindFirstChild(""..argument).Disabled = false
					wait(0.5)
				end
			else
				local cut = plr.PlayerGui.Cutscenes:FindFirstChild(""..argument)
				for i,x in pairs (game.Players:GetPlayers()) do
					x.PlayerGui.Cutscenes:FindFirstChild(""..argument).Disabled = true
					x.PlayerGui.Cutscenes:FindFirstChild(""..argument):Destroy()
					i = FixCam.FixCamera
					i.Disabled = false
					i:Clone().Parent = x.PlayerGui
				end
				cut:Destroy()
			end
		elseif Play == "Off" then
			for i,x in pairs (game.Players:GetPlayers()) do
				x.PlayerGui.Cutscenes:ClearAllChildren()
				i = FixCam.FixCamera
				i.Disabled = false
				i:Clone().Parent = x.PlayerGui
			end
		elseif Play == "Finished" then
			local Input = args[1]
			assert(type(Input) == "string","Cutscene Invalid - Not a String")
			local Scene = assert(plr.PlayerGui.Cutscenes:FindFirstChild(Input), "Cutscene not Found")
			Scene:Destroy()
			print("Scene Destroyed")
		end
	end
end)
Event Script Idea, not using as it didn't work.
--Made By MillerrIAm
-------------Variables------------
Event = game.ReplicatedStorage.ExtraEvents.CutsceneAllowance
------------Main Script------------
Event.OnServerEvent:Connect(function(plr,Checking)
	if Checking == "True" then
		local startergui = game.StarterGui
		local playergui = plr.PlayerGui
		if playergui:FindFirstChild("Cutscenes") then
			plr.PlayerGui.Cutscenes:Destroy()
		elseif not playergui:FindFirstChild("Cutscenes") then
			local Folder = Instance.new("Folder")
			Folder.Name = "Cutscenes"
			Folder.Parent = plr.PlayerGui
		end
	end
end)
GUI Button Local Script
--Made By MillerrIAm
------------Main Script------------
script.Parent.MouseButton1Click:Connect(function()
	if game.Workspace.CutsceneValue.Value == true then
		game.Workspace.CutsceneValue.Value = false
		script.Parent.Text = "Cutscenes: On"
		if not script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("Cutscenes") then
			local Folder = Instance.new("Folder")
			Folder.Name = "Cutscenes"
			Folder.Parent = script.Parent.Parent
		end
	else
		game.Workspace.CutsceneValue.Value = true
		script.Parent.Text = "Cutscenes: Off"
		script.Parent.Parent.Parent.Parent.Parent.Cutscenes:Destroy()
	end
end)

Thank you in advance for any help you can give me.

4 Likes

I’m not entirely sure what your main issue is, perhaps due to a poor explanation or perhaps to my own negligence, but I’ll give an answers to fix the error you seem to be running into.

With what you are trying to create, it’s going to be very beneficial to use an external, stand-alone value rather than an internal one that would reset each time you spawn. To accomplish this, (as I assume you already have an internal value that checks whether or not the cutscenes are disabled or not), make sure that ScreenGUI > ResetOnSpawn is set to false.

image

When you ensure that your Camera System GUI will not reset on spawn, you can create a bool value which is checked for each time .CharacterAdded is fired. From there it’s as simple as:

if BoolValue.Value then
   -- Disable Cutscenes
else
   -- Leave Cutscenes Enabled
end

Once again, I’m not entirely sure if this answers your questions but hopefully it is atleast a start.

3 Likes

You hit the problem head on, my issue is attempting to make sure the cutscenes stay disabled on respawn.

So, I use a CutsceneCheckScript that deletes itself after going through each respawn as for some odd reason, I couldn’t get it to load during the CharacterAdded function.