Changing shadow lighting from pressing a key doesnt keep its state after respawning or walking around

im trying to make a script when you press G it should turn GlobalShadows Off else turn it On but respawning or walking around for a bit restarts back to it being On

--local script in starterplayerscripts
uis.InputBegan:Connect(function(Input,proc)
	if not proc then
		if Input.UserInputType == Enum.UserInputType.Keyboard then
			
			if Input.KeyCode == Enum.KeyCode.G then
				local shad = game.Lighting.GlobalShadows
				shad = false
            else 
                shad = true
			end
		end
	end	
end)

any help?

1 Like

If you press any other key it goes back to being false. But you never changed the property itself anyway.

if Input.KeyCode == Enum.KeyCode.G then
	game.Lighting.GlobalShadows = not game.Lighting.GlobalShadows
end

This will toggle it on and off.

2 Likes

I do not understand what you mean? Can you elaborate?

1 Like

Sorry sorry not boolean i mean will this effect server changes? like is it just for player itself or it will change the whole game lighting?

1 Like

It will only be a local change. if you want it for everyone to see use remote events.

2 Likes