My Transition script in StarterGui isn't local. It keep showing transition to everyone when one person activate it

  1. What do you want to achieve? Keep it simple and clear!

I want to fix my script and make it local, not showing to everyone when one player activate trigger for transition (eg. teleporation)

  1. What is the issue? Include screenshots / videos if possible!

It’s not local; anybody who trigger transition event ( teleporting to shop, etc…), it’s showing transition to everyone. Very annoying and definitely need to fix lol

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I did and tried some stuff like making script local but it didn’t work.

Here’s code:

local tween = game:GetService("TweenService")
local ui = script.Parent
local darkness = game.Lighting.ColorCorrection

local player = game:GetService("Players").LocalPlayer



--|| DARKNESS TRIGGER LIST ||--

local part1 = workspace.TP1
local part2 = workspace.Hole
local part3 = workspace.BunkHole

--|| DARKNESS TRIGGER LIST ||--



--|| TRIGGER 1 ||--

part1.Touched:Connect(function(hit)

	tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
	tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
	wait(1.5)

	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

	tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
	tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
end)

--|| TRIGGER 2 ||--

part2.Touched:Connect(function(hit)

	tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
	tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
	wait(1.5)

	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

	tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
	tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
end)

--|| TRIGGER 3 ||--

part3.Touched:Connect(function(hit)

	tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
	tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
	wait(1.5)

	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

	tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
	tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
end)

Thanks a lot!

you must check if the player who touched the part is actually a player

if not hit.Parent:FindFirstChild("Humanoid") then return end

also, can you add a print after the Touched Event?

Yes, @ayoub50 is right. If you don’t test if the thing touched is a player, then it will tween the darkness for the player even if your touchpart is touching the floor.

The reason it is playing for all players is because the trigger is continuously touching something, therefore triggering the tween.

Hey, sorry for late reponse! I have been really busy. Anyways, so I added humanoid check and it broke whole script.

Did I do something wrong?

local tween = game:GetService("TweenService")
local ui = script.Parent
local darkness = game.Lighting.ColorCorrection

local player = game:GetService("Players").LocalPlayer



--|| DARKNESS TRIGGER LIST ||--

local part1 = workspace.World.TP1
local part2 = workspace.World.Hole
local part3 = workspace.World.BunkHole

--|| DARKNESS TRIGGER LIST ||--



--|| TRIGGER 1 ||--

part1.Touched:Connect(function(hit)
	local h1 = part1.Parent:findFirstChild("Humanoid")
	if h1~=nil then
		tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
		tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
		wait(1.5)

		--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
		--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
		--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
		--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
		--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
		--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

		tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
		tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
	end

	--|| TRIGGER 2 ||--

	part2.Touched:Connect(function(hit)
		local h2 = part2.Parent:findFirstChild("Humanoid")
		if h2~=nil then
			tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
			tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
			wait(1.5)

			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

			tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
			tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
		end

		--|| TRIGGER 3 ||--

		part3.Touched:Connect(function(hit)
			local h3 = part3.Parent:findFirstChild("Humanoid")
			if h3~=nil then
				tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
				tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
				wait(1.5)

				--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
				--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
				--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
				--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
				--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
				--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

				tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
				tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
			end
		end)
	end)
end)

So if you are using the .touched event then you either need a server script or you need to put the localscript inside of starterplayerscripts.

Edit: Also, you need to use hit.Parent, not part1.Parent

Hey, thanks in advance. Transition works now BUT it still have same problem; tweening darkness for EVERYONE, not to local.

What I do now?

Also, I just tried changing script to local and putting it in StarterPlayerScripts, it just broke whole script. I also changed UI’s script to make it work there but it failed.

Make your script fire a remote event when the part is touched to the player who touched it and have a local script tween their lighting instead.

Hey, I added fire remote event for trigger and receiver in script. It didn’t work, still showing for everyone and some weird error appeared.

image
and other eror, this.

Pretty sure I did something horribly wrong from look of this error, also here’s same script but with remote events added.

local tween = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer


local ui = player.PlayerGui:WaitForChild("Teleporter")
local darkness = game.Lighting.ColorCorrection

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TransitionTrigger")



--|| DARKNESS TRIGGER LIST ||--

local part1 = workspace.World.TP1
local part2 = workspace.World.Hole
local part3 = workspace.World.BunkHole

--|| DARKNESS TRIGGER LIST ||--



--|| TRIGGER 1 ||--

part1.Touched:Connect(function(hit)
	if remoteEvent.OnClientEvent:Connect() then
		local h1 = hit.Parent:findFirstChild("Humanoid")
		if h1~=nil then
			tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
			tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
			wait(1.5)

			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

			tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
			tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
		end

		--|| TRIGGER 2 ||--

		part2.Touched:Connect(function(hit)
			if remoteEvent.OnClientEvent:Connect() then
				local h2 = hit.Parent:findFirstChild("Humanoid")
				if h2~=nil then
					tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
					tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
					wait(1.5)

					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

					tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
					tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
				end

				--|| TRIGGER 3 ||--

				part3.Touched:Connect(function(hit)
					if remoteEvent.OnClientEvent:Connect() then
						local h3 = hit.Parent:findFirstChild("Humanoid")
						if h3~=nil then
							tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
							tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
							wait(1.5)

							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

							tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
							tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
						end
					end
				end)
			end
		end)
	end
end)

Oh, I almost forgot. The script where trigger for firing remote events.

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“TransitionTrigger”)

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
		remoteEvent:Fire()
		hit.Parent.HumanoidRootPart.Position = game.workspace.World.Teleport2.Position
	end
end)

You are on the right track already but change this line

To
if h1 ~= nil and h1 == player.Character then

The reason why it doing this is because you check if any character touch it then it will activate instead of just the character of localscirpt player

Also revert back to localscirpt and put in starterGui it should work just fine

EDIT: Since I quote old script don’t forget to change
local h1 = part1.Parent:findFirstChild("Humanoid")
To
local h1 = hit.Parent:FindFirstChild("Humanoid")
Too

1 Like

First of all, for RemoteEvents, you use FireServer() or FireClient().

Second of all, you need to move the tweenservice lines into a local script inside of StarterPlayerScripts.

Third of all, you need a remote event for each part, so I suggest making a folder for them.

Fourth, you need to use FireClient() to the player who touched the part once the part is touched.

Fifth, inside of the local script in StarterPlayerScripts, connect a function when the .OnClientEvent thing is true.

Sorry it is a lot, hope it helps you out :slightly_smiling_face:

1 Like

Thank y’ll for advices, but sigh… it still doesn’t work.

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“TransitionTrigger”)

This is script in workspace, aka teleporation/transition trigger.

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
		remoteEvent:FireClient()
		hit.Parent.HumanoidRootPart.Position = game.workspace.World.Teleport2.Position
	end
end)

This is same script from StarterPlayerScripts, I also tried to put it in StarterGui; following RandomPlayerOne1’s advice but didn’t work either.

local tween = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer


local ui = player.PlayerGui:WaitForChild("Teleporter")
local darkness = game.Lighting.ColorCorrection

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TransitionTrigger")



--|| DARKNESS TRIGGER LIST ||--

local part1 = workspace.World.TP1
local part2 = workspace.World.Hole
local part3 = workspace.World.BunkHole

--|| DARKNESS TRIGGER LIST ||--



--|| TRIGGER 1 ||--

part1.Touched:Connect(function(hit)
	if remoteEvent.OnClientEvent:Connect() then
		local h1 = hit.Parent:FindFirstChild("Humanoid")
		if h1 ~= nil and h1 == player.Character then
			tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
			tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
			wait(1.5)

			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
			--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

			tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
			tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
		end

		--|| TRIGGER 2 ||--

		part2.Touched:Connect(function(hit)
			if remoteEvent.OnClientEvent:Connect() then
				local h2 = hit.Parent:FindFirstChild("Humanoid")
				if h2 ~= nil and h2 == player.Character then
					tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
					tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
					wait(1.5)

					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
					--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

					tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
					tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
				end

				--|| TRIGGER 3 ||--

				part3.Touched:Connect(function(hit)
					if remoteEvent.OnClientEvent:Connect() then
						local h3 = hit.Parent:FindFirstChild("Humanoid")
						if h3 ~= nil and h3 == player.Character then
							tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
							tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
							wait(1.5)

							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
							--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

							tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
							tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
						end
					end
				end)
			end
		end)
	end
end)

First Error


Next Error after the first one

Pretty much, that’s what is going on.

Edit: fixed some typos

1 Like

Did you remove these remote event line when you tried my method? I don’t think you need these

And also this is a wrong way to use remote event.OnClientEvent :sweat_smile:

Lol I am not good with remote events but thanks for letting me know that, so what’s right way?

Edit: Pretty sure I didn’t remove remote event lines tho

Try remove them (all remoteEvent.OnClientEvent:Connect()) part I can’t edit the whole script rn because my phone is a bit funky

Yeah inside the local script replace this:

part1.Touched:Connect(function(hit)
    if remoteEvent.OnClientEvent then

With this:

remoteEvent.OnClientEvent:Connect(function(plr) — for the player

Also, there should be none of this in your local script:

local h1 = hit.Parent:FindFirstChild("Humanoid")
		if h1 ~= nil and h1 == player.Character then

You didn’t add any checks if the object that touched the part belongs to a player and if that player is the LocalPlayer.

Try this:

local tween = game:GetService("TweenService")
local ui = script.Parent
local darkness = game.Lighting.ColorCorrection

local player = game:GetService("Players").LocalPlayer



--|| DARKNESS TRIGGER LIST ||--

local part1 = workspace.TP1
local part2 = workspace.Hole
local part3 = workspace.BunkHole

--|| DARKNESS TRIGGER LIST ||--



--|| TRIGGER 1 ||--

part1.Touched:Connect(function(hit)
    if not hit.Parent:FindFirstChild("Humanoid") return end -- Checks if the hit part belongs to a character

    local foundPlayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- Checks if the character is associated with a Player.
    if not foundPlayer then return end
    if foundPlayer ~= player then return end -- Checks if the found player is the current player (LocalPlayer).

tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
	tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
	wait(1.5)

	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

	tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
	tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
end)

--|| TRIGGER 2 ||--

part2.Touched:Connect(function(hit)
    if not hit.Parent:FindFirstChild("Humanoid") return end -- Checks if the hit part belongs to a character

    local foundPlayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- Checks if the character is associated with a Player.
    if not foundPlayer then return end
    if foundPlayer ~= player then return end -- Checks if the found player is the current player (LocalPlayer).

	tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
	tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
	wait(1.5)

	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

	tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
	tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
end)

--|| TRIGGER 3 ||--

part3.Touched:Connect(function(hit)
    if not hit.Parent:FindFirstChild("Humanoid") return end -- Checks if the hit part belongs to a character

    local foundPlayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- Checks if the character is associated with a Player.
    if not foundPlayer then return end
    if foundPlayer ~= player then return end -- Checks if the found player is the current player (LocalPlayer).

	tween:Create(darkness,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = -1}):Play()
	tween:Create(ui.black,TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 0}):Play()
	wait(1.5)

	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--
	--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--||--

	tween:Create(darkness,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Brightness = 0}):Play()
	tween:Create(ui.black,TweenInfo.new(0.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{BackgroundTransparency = 1}):Play()
end)

Hey, good news; one error is gone but second error still exists.


Thanks for your help! I really appericate y’ll.

Can you show me that script if possible?

Apparently I forgot to delete Remote Event Trigger for teleport.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TransitionTrigger")


script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("HumanoidRootPart") then
		remoteEvent:FireClient()
		hit.Parent.HumanoidRootPart.Position = game.workspace.World.Teleport2.Position
	end
end)