Need help! Ambient wont change color! [SOLVED]

You can write your topic however you want, but you need to answer these questions:

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

I want to make be able to set the ambient from three TextButtons on a PlayerGui (R, G, and B respectively)

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

For whatever reason, i cannot deduce why when i fire the button it changes the ambient to 0,0,0 or no change at all regardless of the input in R,G,B.
Could it be that im using an entirely WRONG method?

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

Ive looked at a lot of posts regarding this topic and haven’t found anything that solves my problem, and I myself have tried this on a local and server script, same problem (but needed on server script otherwise it will only show for the client)

local re = script.Parent.ChangeEv
local lighting = game:GetService("Lighting")
	

re.OnServerEvent:Connect(function(player)


	local r = tonumber(player.PlayerGui.ChangeAmbient.Background.R.Text)
	local g = tonumber(player.PlayerGui.ChangeAmbient.Background.G.Text)
	local b = tonumber(player.PlayerGui.ChangeAmbient.Background.B.Text)
	
	lighting.Ambient = Color3.new(r,g,b)
	
	
	print("ambient changed to "..lighting.Ambient.R, lighting.Ambient.G, lighting.Ambient.B, "by ".. player.Name)
end)

If any further clarification is needed, please reply asking for me to do so.

GIF of what exactly is happening:
for some reason, the print still works. I’m clueless, but then again i’m also not a scripter.

https://i.gyazo.com/665244ab7abe24167e61274f22c74cb8.mp4

1 Like

Client changes to PlayerGui are not replicated to the server, thus you cannot do this :

local r = tonumber(player.PlayerGui.ChangeAmbient.Background.R.Text)
local g = tonumber(player.PlayerGui.ChangeAmbient.Background.G.Text)
local b = tonumber(player.PlayerGui.ChangeAmbient.Background.B.Text)

Simple fix - Change your remote event such that the client will pass the values they entered to the server.

i apologize for not asking this earlier, and for my lack of knowledge on remotes, but how exactly would i do that?

-- CLIENT

Button.Activated:Connect(function()
	local r = tonumber(PlayerGui.ChangeAmbient.Background.R.Text)
	local g = tonumber(PlayerGui.ChangeAmbient.Background.G.Text)
	local b = tonumber(PlayerGui.ChangeAmbient.Background.B.Text)
	
	remoteEvent:FireServer(r, g, b)
end)

-- SERVER

re.OnServerEvent:Connect(function(player, r, g, b)
	lighting.Ambient = Color3.new(r,g,b)


	print("ambient changed to "..lighting.Ambient.R, lighting.Ambient.G, lighting.Ambient.B, "by ".. player.Name)
end)
1 Like