Teleports Broken when Touch Lighting Is there

VIDEO REFERENCE:

It’s a youtube link since this forum keeps telling me “error” when uploading sorry.

Heres the code I’m using for the lighting :


local part = script.Parent

local function changeLightingAndEffects()
	local Lighting = game:GetService("Lighting")

	Lighting.Ambient = Color3.new(0.517647, 0.466667, 0.631373)
	Lighting.Brightness = 9.58
	Lighting.ColorShift_Bottom = Color3.new(0.666667, 0, 0.498039)
	Lighting.ColorShift_Top = Color3.new(0.411765, 0.368627, 1)
	Lighting.EnvironmentDiffuseScale = 0.186
	Lighting.EnvironmentSpecularScale = 1
	Lighting.OutdoorAmbient = Color3.new(0.211765, 0.152941, 0.262745)
	Lighting.ShadowSoftness = .32
	Lighting.TimeOfDay = 0
	Lighting.GeographicLatitude = 0

	local bloom = Lighting:FindFirstChildOfClass("BloomEffect")
	if bloom then
		bloom.Intensity = .2
		bloom.Threshold = 0.5
		bloom.Size = 2
	end

	local atmosphere = Lighting:FindFirstChildOfClass("Atmosphere")
	if atmosphere then
		atmosphere.Density = 0.304
		atmosphere.Offset = 0.712
		atmosphere.Color = Color3.new(0.737255, 0.505882, 1)
		atmosphere.Decay = Color3.new(0.666667, 0, 0.498039)
		atmosphere.Glare = 0.64
		atmosphere.Haze = 0.76
	end

	local depthOfField = Lighting:FindFirstChildOfClass("DepthOfFieldEffect")
	if depthOfField then
		depthOfField.FarIntensity = 1
		depthOfField.FocusDistance = 11.2
		depthOfField.InFocusRadius = 23.2
		depthOfField.NearIntensity = 1
	end
end

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		changeLightingAndEffects()
	end
end)

Is there an easier way to do the lighting in a single area, or am I missing a code to fix the teleports?

2 Likes

I pretty much think that the script used for the lighting interfere with the teleport script somehow. Try replacing the lighting Script by a Local Script and use a script to detect the player touching the part:

local Event = game:GetService("ReplicatedStorage").RemoveEvent

local Part = script.Parent

game.Players.PlayerAdded:Connect(function(Player)
	Part.Touched:Connect(function(touched)
		if Player.Character == touched.Parent then
			Event:FireClient(Player)
		end
	end)	
end)

(Put the script in the part)

Add a RemoteEvent in ReplicatedStorage (name it whatever you want)

Next take the lighting local script and place it in StarterPlayerScripts and add this piece of code:

local Event = game:GetService("ReplicatedStorage").RemoteEvent

Event.OnClientEvent:Connect(function()
	local Lighting = game:GetService("Lighting")

	Lighting.Ambient = Color3.new(0.517647, 0.466667, 0.631373)
	Lighting.Brightness = 9.58
	Lighting.ColorShift_Bottom = Color3.new(0.666667, 0, 0.498039)
	Lighting.ColorShift_Top = Color3.new(0.411765, 0.368627, 1)
	Lighting.EnvironmentDiffuseScale = 0.186
	Lighting.EnvironmentSpecularScale = 1
	Lighting.OutdoorAmbient = Color3.new(0.211765, 0.152941, 0.262745)
	Lighting.ShadowSoftness = .32
	Lighting.TimeOfDay = 0
	Lighting.GeographicLatitude = 0

	local bloom = Lighting:FindFirstChildOfClass("BloomEffect")
	if bloom then
		bloom.Intensity = .2
		bloom.Threshold = 0.5
		bloom.Size = 2
	end

	local atmosphere = Lighting:FindFirstChildOfClass("Atmosphere")
	if atmosphere then
		atmosphere.Density = 0.304
		atmosphere.Offset = 0.712
		atmosphere.Color = Color3.new(0.737255, 0.505882, 1)
		atmosphere.Decay = Color3.new(0.666667, 0, 0.498039)
		atmosphere.Glare = 0.64
		atmosphere.Haze = 0.76
	end

	local depthOfField = Lighting:FindFirstChildOfClass("DepthOfFieldEffect")
	if depthOfField then
		depthOfField.FarIntensity = 1
		depthOfField.FocusDistance = 11.2
		depthOfField.InFocusRadius = 23.2
		depthOfField.NearIntensity = 1
	end
end)

What I did is that I replaced the lighting script by a Local Script to make the lighting change only of the specific client and detected if this client was touching the part via the script. If so the script would trigger the RemoteEvent, giving to the LocalScript the fact that the player touched the part.

3 Likes

I don’t know why I didn’t think of local scripts! I guess I forgot, thank you for the suggestion! However, I followed word for word and ended up with no results.

image
image
image


(Lighting the same as studio lighting)

I saved my original code of course, and disabled the script. This might just be something extremely simple and I’m just not able to get it, but thank you so very much for helping nonetheless ^^

1 Like

Update! After playing around, the issue has turned into the game not recognizing the player is touching the part.

image

I have the same scripts you’ve provided in use, I tested with my original broken teleports script to be sure that was the case.