How would I get this script to stop?

Hello! So I have a cutscene script and I added a skip button. The skip button works but I wanted to see how I could stop the cutscene and all after everyone skips?

this is a localscript

local UserInputService = game:GetService("UserInputService")
local TextLabel = script.Parent.Parent.Frame.TextLabel
local Lighting = game.Lighting
local Hour = game.ReplicatedStorage.Game.Hour
local Sounds = game.Workspace.Sounds.CutsceneSound

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = 0
local starterGui = game:GetService("StarterGui")
while not pcall(starterGui.SetCore, starterGui, "ResetButtonCallback", false) do
	task.wait()
end

local Text

function introText(word)
	Text = word
	for i = 1, #Text do
		TextLabel.Text = string.sub(Text, 1, i)
		TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
		wait(0.04)
	end
end

local debouce = false
local VoiceLines = Sounds.VoiceLines
local VoiceLineText = script.Parent.Parent.VoiceLineText

--Game Start
game.ReplicatedStorage.RemoteEvents.CutsceneStart.OnClientEvent:Connect(function()
		if debouce == false then
			debouce = true
			local TweenService = game:GetService("TweenService")
			local cutsceneTime = 20
			local Camera = game.Workspace.CurrentCamera
			local CameraPart = script.CameraPart
			local CameraPart1 = script.CameraPart1
			local CameraPart2 = script.CameraPart2
			local CameraPart3 = script.CameraPart3
			VoiceLines["car start"]:Play()
			wait(3)
			VoiceLines["car start"]:Stop()
			wait(1)
			Camera.CameraType = Enum.CameraType.Scriptable
			Camera.CFrame = CameraPart.CFrame
			VoiceLines["Car Engine"].Looped = true
			VoiceLines["Car Engine"]:Play()
			VoiceLines.CarMusic:Play()
			wait(1.5)
			CameraPart1.Parent = game.Workspace
			script.Parent.Parent.Frame.Visible = false
			VoiceLineText.Visible = true
			script.StartMap.Parent = game.Workspace
			script.Parent.Parent.Frame.Visible = false
			VoiceLineText.Text = ""
			wait(2.5)
			Camera.CFrame = CameraPart1.CFrame
			VoiceLines.CarMusic:Stop()
			VoiceLines["FNAF: Voice Line"]:Play()
			VoiceLineText.Text = "Hey! Am listening to that man!"
			wait(2.5)
			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()
				VoiceLines["FNAF: Voice Line 1"]:Play()
				VoiceLineText.Text = "Yo bro why are we signing up for this place?"
				wait(2.5)
				VoiceLineText.Text = "I heard they were paying up to 120 dollars so we have to take this offer"
				VoiceLines["FNAF: Voice Line 2"]:Play()
				wait(3.5)
				VoiceLineText.Text = "Well why did you even bring us?"
				wait(3)
				VoiceLineText.Text = "Well I can split the money with all of you... if only you help me."
				VoiceLines["FNAF: Voice Line 3"]:Play()
				wait(6)
				VoiceLineText.Text = "Alright."
				wait(1)
				script.Parent.Parent.Frame.Visible = true
				VoiceLines["Car Engine"].Looped = false
				VoiceLines.CarMusic:Stop()
				local Player = script.Parent.Cutscenes.Issac
				Player.Parent = game.Workspace
				local Player2 = script.Parent.Cutscenes.Henry
				Player2.Parent = game.Workspace
				local Player4 = script.Parent.Cutscenes.Zack
				Player4.Parent = game.Workspace
				game.Lighting.ClockTime = 4
				game.Lighting.Ambient = Color3.new(0, 0, 0)
				wait(2)
				game.Workspace.StartMap:Destroy()
				script.Parent.Parent.Frame.Visible = false
				tween:Cancel()
				Camera.CFrame = CameraPart3.CFrame
				VoiceLineText.Text = " So this is the place?"
				VoiceLines["Ceiling fan sound loop"]:Play()
				VoiceLines["FNAF: Voice Line 4"]:Play()
				wait(2.5)
				VoiceLineText.Text = " It looks abanded. I dont think it was a right choice coming here..."
				VoiceLines["FNAF: Voice Line 6"]:Play()
				wait(5)
				VoiceLineText.Text = " Well the doors are locked so we have no other choice."
				VoiceLines["FNAF: Voice Line 5"]:Play()
				wait(3)
				Lighting.Ambient = Color3.new(0.121569, 0.121569, 0.121569)
				Player:Destroy()
				Player2:Destroy()
				Player4:Destroy()
			end
			tween(CameraPart1,CameraPart2)
			VoiceLineText.Text = ""
			VoiceLineText.Visible = false
			script.Parent.Parent.Frame.Visible = true
			script.Parent.Parent.Frame.TextLabel.Visible = true
			script.Parent.Parent.Frame.TextLabel2.Visible = true
			script.Parent.Parent.Frame.TextLabel2.Text = "Night ".. game.ReplicatedStorage.Game.Night.Value
			VoiceLines["Ceiling fan sound loop"]:Stop()
			introText("12:00 AM")
			wait(3)
			script.Parent.Parent.Frame.TextLabel2.Visible = false
			script.Parent.Parent.Frame.Visible = false
			game.ReplicatedStorage.RemoteEvents.CutsceneEnd:FireServer()
			game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 11
			game.Players.LocalPlayer.PlayerGui.CharacterGui.Enabled = true
		game.Players.LocalPlayer.PlayerGui.CharacterGui.MainFrame.Visible = true
	end
end)


local Camera = game.Workspace.CurrentCamera

game.ReplicatedStorage.RemoteEvents.CharacterChoosen.OnClientEvent:Connect(function(Player)
	Camera.CameraType = Enum.CameraType.Custom
	script.Parent.Parent.ControlFrame.Visible = true
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 11
	game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0
end)

game.ReplicatedStorage.RemoteEvents.StartingSoon.OnClientEvent:Connect(function()
	local Debounce = false
	if Debounce == false then
		Debounce = true
		game.ReplicatedStorage.RemoteEvents.StartingSoon:FireServer()
	end
end)


local Players = game:GetService("Players")
local Value  = script.Parent.Parent.SkipButton.Skips
local PlayerCount = #Players:GetPlayers()

while task.wait(0.1) do
	if Value.Value == PlayerCount then
		Camera.CameraType = Enum.CameraType.Custom
		VoiceLines.CarMusic:Stop()
		VoiceLines["car start"]:Stop()
		VoiceLines["Car Engine"]:Stop()
		VoiceLineText.Text = ""
		VoiceLineText.Visible = false
		script.Parent.Parent.Frame.Visible = true
		script.Parent.Parent.Frame.TextLabel.Visible = true
		script.Parent.Parent.Frame.TextLabel2.Visible = true
		script.Parent.Parent.Frame.TextLabel2.Text = "Night ".. game.ReplicatedStorage.Game.Night.Value
		VoiceLines["Ceiling fan sound loop"]:Stop()
		introText("12:00 AM")
		wait(3)
		script.Parent.Parent.Frame.TextLabel2.Visible = false
		script.Parent.Parent.Frame.Visible = false
		game.ReplicatedStorage.RemoteEvents.CutsceneEnd:FireServer()
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 11
		game.Players.LocalPlayer.PlayerGui.CharacterGui.Enabled = true
		game.Players.LocalPlayer.PlayerGui.CharacterGui.MainFrame.Visible = true
	end
end

i only want the cutscene start remote event to stop after everyone skips

I mean considering that it is a localscript I’d probably just delete it lol. However if you do wish to code it in, look into coroutines (I think you can use them to stop code, but you might have to fact check it)

Can you clarify what part of your code you want to stop? The while loop at the end?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.