[SOLVED] Why is my script is teleporting all the players but not removing the fade screen UI?

Hello developers,

I’m making a horror facility game but, look, this is not working the way i wanted it to:

local CollectionService = game:GetService("CollectionService")
local TS = game:GetService("TweenService")
local ComputersNeeded = 3
local ComputersCompleted = 2

for _, Computer in pairs(CollectionService:GetTagged("Computer")) do
	local Prompt = Instance.new("ProximityPrompt")
	-- localizar os computadores mais faceis (só quando o jogo estiver em teste)
	
	--local Highlight = Instance.new("Highlight")
	--Highlight.Parent = Computer
	
	--script
	Prompt.Enabled = true
	Prompt.Parent = Computer.Screen.Attachment
	Prompt.ActionText = "Hack"
	Prompt.ObjectText = "Computer"
	Prompt.HoldDuration = 2
	Prompt.Triggered:Connect(function(Player)
		local ComputerGui = Player.PlayerGui.ComputerGui
		local DisplayX = ComputerGui.Display.Position.X
		
		TS:Create(ComputerGui.Display, TweenInfo.new(
			1,
			Enum.EasingStyle.Back,
			Enum.EasingDirection.Out
			),
			{Position = UDim2.new(DisplayX, 0, 0, 0)}
		):Play()
		ComputerGui.Display.Text = "Computers hacked: "..ComputersCompleted.."/"..ComputersNeeded
		task.delay(1.05, function()
			if ComputersCompleted < 3 then
				ComputerGui.Display.Text = "Computers hacked: "..ComputersCompleted.."/"..ComputersNeeded
			else
				ComputerGui.Display.Text = "All computers hacked, find the exit"
			end
		end)
		task.delay(4, function()
			if ComputersCompleted < 3 then
				TS:Create(ComputerGui.Display, TweenInfo.new(
					1,
					Enum.EasingStyle.Back,
					Enum.EasingDirection.In
					),
					{Position = UDim2.new(0.283, 0, -0.1, 0)}
				):Play()
			end
		end)
		ComputersCompleted += 1
		Prompt.Enabled = false
	end)
end

repeat task.wait()
	
until ComputersCompleted >= ComputersNeeded

local Highlight = Instance.new("Highlight")
local Prompt = Instance.new("ProximityPrompt")
local Debounce = false
Highlight.Parent = workspace.ComputerExit.GarageDoorExit
Prompt.Parent = workspace.ComputerExit.GarageDoorExit
Prompt.ActionText = "Enter"
Prompt.ObjectText = "Garage Door"
Prompt.Triggered:Connect(function()
	if Debounce == false then
		Debounce = true
		for _, ServerPlayer in ipairs(game.Players:GetPlayers()) do
			local FadeScreen = ServerPlayer.PlayerGui.ComputerGui.FadeScreen
			local ServerCharacter = ServerPlayer.Character or ServerPlayer.CharacterAdded:Wait()
			FadeScreen.Visible = true
			ServerCharacter.HumanoidRootPart.CFrame = workspace.Facility.FacilityEnterPart.CFrame
			ServerPlayer.PlayerGui.ComputerGui.Display.Visible = false
			game.ServerScriptService.LightOff.Enabled = false
			game.Lighting.TimeOfDay = 12
			game.ReplicatedStorage.LightOffSounds:Destroy()
			game.SoundService.Ambience:Stop()
			game.SoundService.AmbientReverb = Enum.ReverbType.Arena
			Highlight:Destroy()
			--workspace.ParkGarage:Destroy()
			task.wait(5)
			TS:Create(FadeScreen, TweenInfo.new(4), {BackgroundTransparency = 1}):Play()
		end
	end
end)
Highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
Highlight.FillColor = Color3.fromRGB(55, 255, 0)

It may look normal, but for some reason, it is not teleporting all the players, and it is bugging out like, BUGGING VERY MUCH. I can’t know why is this happening, but can you guys help me?

Thank you.

Edit: I think i may have saw the problem, the problem is that the player is teleporting succefully, but the screen gui is not being invisible anymore for the other player, only for the player that triggered the prompt.

–laheitorzito303030

5 Likes

It may be because of this, CFrames hold both positions and orientation. So choose the pos of the CFrame only.

2 Likes

I already got what it is, it is teleporting the players, but it is not removing the screen gui after some time. only for the player that triggered the prompt, but for the other players that don’t happen.

Guys i solved it, i finally solved it!!! YEAAAAAAAAAAAA

If you’re gonna give yourself solution at least explain what you changed so it can be a resource for other people.

1 Like

It was because of that line:

game.ReplicatedStorage.LightOffSounds:Destroy()

I think it was trying to destroy 2 light off which was bugging it and caused errors

1 Like

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