Local script running for all players, not just one

I’ve created a script that plays a cutscene after an event is launched. The cutscene plays some music, and shows some guis. But when I try to test this with multiple people, every player can hear the music and see the guis show up, even when I don’t want them to. I can find a workaround for the guis, but if there are two people playing the cutscene at the same time, the music plays twice.

The script is inside a LocalScript, so it should run only for the player. To fire the event, I used FireAllClients().

game.ReplicatedStorage.MapWonEvent.WorkChosen.OnClientEvent:Connect(function()
	game.Players.LocalPlayer.PlayerGui.BackGui.Frame.Visible = false
	game.Players.LocalPlayer.PlayerGui.BackGui.BackClicker.Visible = false
	TweenService:Create(game.Players.LocalPlayer.PlayerGui.FadeGui.Frame,TweenInfo.new(1.5,Enum.EasingStyle.Linear),{BackgroundTransparency = 0}):Play()
--This fade effect also plays multiple times when multiple people are trying to use it
	task.wait(1.5)
	TweenService:Create(game.Players.LocalPlayer.PlayerGui.FadeGui.Frame,TweenInfo.new(0.5,Enum.EasingStyle.Linear),{BackgroundTransparency = 1}):Play()
	local camera = game.Workspace.CurrentCamera
	local playerPositions = game.Workspace.WorkMap.PlayerPositions
	local cameraHolder = game.Workspace.WorkMap.PlayerCams
		game.Lighting.ClockTime = 9
		game.Workspace.Work:Play() -- The sound I am trying to play
		Controls:Disable() -- Disables the player's controls
		camera.CFrame = cameraHolder.Camera1.CFrame
task.wait(3)
		camera.CFrame = cameraHolder.Camera2.CFrame
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = playerPositions.PlayerPos1.CFrame
		game.Players.LocalPlayer.Character.Humanoid:MoveTo(playerPositions.PlayerPos2.Position)
		task.wait(2.2)
		textLabel.BorderColor3 = Color3.fromHSV(0, 0, 1)
		textLabel.TextColor3 = Color3.fromHSV(0, 0, 1)
		textLabel.Visible = true
		typewrite(textLabel, "General!", 0.04) -- The text overlaps when multiple players are using it, so you cannot read this at all
		task.wait(0.3)
		textLabel.Visible = false
		task.wait(2)
		textLabel.Visible = true
		textLabel.BorderColor3 = Color3.fromHSV(0.333333, 1, 0.301915)
		textLabel.TextColor3 = Color3.fromHSV(0.333333, 1, 0.301915)
		typewrite(textLabel, "Solder, why aren't you in rank?", 0.05) --For example, this message might be playing for one player, while the last one is playing for another, but both players can see them at the same time
		task.wait(1)
		textLabel.BorderColor3 = Color3.fromHSV(0, 0, 1)
		textLabel.TextColor3 = Color3.fromHSV(0, 0, 1)
		typewrite(textLabel, "What's going on?", 0.05)
		task.wait(1)
		textLabel.BorderColor3 = Color3.fromHSV(0.333333, 1, 0.301915)
		textLabel.TextColor3 = Color3.fromHSV(0.333333, 1, 0.301915)
		typewrite(textLabel, "I briefed all of you this morning, now grab a weapon and get out there!", 0.04)
	end
end)

Does anybody know why multiple people can see this cutscene?

Its because your using fireallclients, just use FireClient and pass in the player that needs the gui/cutscene

1 Like

If I fire it for multiple players at the same time, will this still work?

Yes, if yu want multiple players to have a cutscene Although its best to assume they will not run at the same time

I am alao using a similar cutscene script and when one player touches the cutscene part then other players involuntary view the same cutscene. That can annoy those who play my obby.

I didnt know about which function causes everyone to view the same cutscene when one player triggers the cutscene block part. I hope this is the solution. Thank you so much.

Don’t revive dead posts man just make a new post.