Trying to change the atmosphere with a part for only the client but doesn't work

Hello!

So recently i have gotten trouble in making a part when touched change the entire atmosphere for the client, but the code doesn’t “ignite”, it just doesn’t change or start

i tried recurring for remoteevents but no success

There’s a part called “RainTrigger” inside a folder called “RainParts”, with a Script and a LocalScript

Here’s both codes for analysis

LocalScript

local TS = game:GetService("TweenService")

local lighting = game:GetService("Lighting")
local Atmosphere = game.Lighting.Atmosphere
local skyboxFolder = lighting.Skyboxes
local rainSkybox = skyboxFolder.RainySky
local normalSky = lighting.NormalSky

local remoteEvent = game.ReplicatedStorage.ChangedAtmosphere

remoteEvent.OnClientEvent:Connect(function()	
	TS:Create(lighting.Ambient, TweenInfo.new(3), {Color3.new(62, 62, 62)}):Play()
	TS:Create(lighting.Brightness, TweenInfo.new(3), {0.5}):Play()
	TS:Create(lighting.OutdoorAmbient, TweenInfo.new(3), {Color3.new(84, 84, 84)}):Play()
	TS:Create(lighting.ClockTime, TweenInfo.new(3), {12}):Play()
	TS:Create(Atmosphere.Density, TweenInfo.new(3), {0.475}):Play()
	TS:Create(Atmosphere.Color, TweenInfo.new(3), {Color3.new(147, 147, 147)}):Play()
	TS:Create(Atmosphere.Decay, TweenInfo.new(3), {Color3.new(92, 92, 92)}):Play()
	TS:Create(Atmosphere.Glare, TweenInfo.new(3), {0}):Play()
	TS:Create(Atmosphere.Haze, TweenInfo.new(3), {10}):Play()
	rainSkybox = lighting
	normalSky = skyboxFolder
end)

Script

local debounce = false

script.Parent.Touched:Connect(function(otherPart)
	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	
	if player then
		
		if debounce then return end
		debounce = true
		
		game.ReplicatedStorage.ChangedAtmosphere:FireClient(player)
		
		task.wait(3)
		
		debounce = false
	end
end)

Try printing otherpart.Parent.Name to make sure it is actually the player model

You’re creating the tweens wrong.
It should be:

TweenService:Create(
   YourObjectWhosePropertiesYouWannaChange,   --In your code, you're putting the property instead of the object
   TweenInfoHere,
   {
       --You're supposed to have the properties as the index and the value as whatever goal you want,
      --Either way is fine, like so:
       PropertyName1Here = SomeValue, 
       ["PropertyName2Here"] = OtherValue 
    }
):Play()

They’re not working still despite being in the same format as yours

remoteEvent.OnClientEvent:Connect(function()
	TweenService:Create(
		lighting,
		TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0),
		{
			Ambient = Color3.new(62, 62, 62),
			Brightness = 0.5,
			OutdoorAmbient = Color3.new(84, 84, 84),
			ClockTime = 12
		}
	):Play()
	
	TweenService:Create(
		Atmosphere,
		TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0),
		{
			Density = 0.475,
			Color = Color3.new(147, 147, 147),
			Decay = Color3.new(92, 92, 92),
			Glare = 0,
			Haze = 10
		}
	):Play()
	
	rainSkybox = lighting
	normalSky = skyboxFolder
end)

I do believe it might be an issue on the remote event part but unsure

yes it prints the player model

Sorry, I forgot you were using TS for TweenService in your original code, you should change it back to TS:Create, but in theory your format should be all good now.

Alright, thanks

But it still won’t work

Oh wait I think i know what the problem is.

Pure LocalScripts should be descendants of Players or Player Characters to actually run. If you want it to be parented to something else you’ll have to create a new default script and change its RunContext property to “LocalScript”. You can just copy the localscript code to the new script but it has to have it’s RunContext property to LocalScript, or you can also just parent your current localscript to StarterPlayer.StarterPlayerScripts / StarterPlayer.StarterCharacterScripts in studio so that your scripts are automatically cloned into players when you play.

1 Like

Thank you so much for the help, it finally runs now

funnily enough it sets the entire lighting to white but i can solve this later on lol

But seriously, thank you so much!

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