Teleporter that changes the lightning of the player who teleported

I am trying to make a teleporter that changes the lightning, but only for the person who teleports, so no one else’s lightning changes.

I have a remote event called “LightEvent” and a script inside a proximity prompt inside the teleporter and this is the script I made:

local ProximityPrompt = script.Parent
local Sound = script.Parent.Parent.Parent.Destination.portal_appear
local RS = game:GetService("ReplicatedStorage")
local LE = RS:WaitForChild("LightEvent")

ProximityPrompt.Triggered:Connect(function(player)
	player.Character.HumanoidRootPart.Position = workspace.Destination.Position
	LE:FireClient(player)
	Sound:Play()
end)

And I also put a local script in StarterPlayerScripts. This is the code I have in it:

local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local LE = RS:WaitForChild("LightEvent")
local Atmosphere = SS:WaitForChild("WinterLightning"):FindFirstChild("WinterAtmosphere")

local Lightning = game.Lighting
local ColorCorrection = Lightning.WinterColorCorrection
local SunRays = Lightning.WinterSunRays

SunRays.Enabled = false
ColorCorrection.Enabled = false

local function mainLight()
	ColorCorrection.Enabled = true
	SunRays.Enabled = true
	local c = Atmosphere:Clone()
	c.Parent = Lightning
	for i,v in pairs(Atmosphere) do
		if v:IsA("Atmosphere") then
			v:Clone().Parent = Lightning
		else
			return
		end
	end
end

LE.OnClientEvent:Connect(mainLight)

And every time I tested it, it didn’t work and didn’t show me any errors.

LocalScripts cannot access ServerStorage.
Try putting everything you need in ReplicatedStorage and change the LocalScript.

Local:

local RS = game:GetService("ReplicatedStorage")
local LE = RS:WaitForChild("LightEvent")
local Atmosphere = RS:WaitForChild("WinterLightning"):FindFirstChild("WinterAtmosphere") --Changed to RS, deleted SS

local Lightning = game.Lighting
local ColorCorrection = Lightning.WinterColorCorrection
local SunRays = Lightning.WinterSunRays

SunRays.Enabled = false
ColorCorrection.Enabled = false

local function mainLight()
	ColorCorrection.Enabled = true
	SunRays.Enabled = true
	local c = Atmosphere:Clone()
	c.Parent = Lightning
	for i,v in pairs(Atmosphere) do
		if v:IsA("Atmosphere") then
			v:Clone().Parent = Lightning
		else
			return
		end
	end
end

LE.OnClientEvent:Connect(mainLight)
1 Like

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