Hello!
I’ve made a script when you press Q the area becomes dark but
somehow it wouldn’t work, is there something wrong with my script?
This is a Local Script located in StarterGui
local Lighting = game.Lighting
local Ambient = Lighting.Ambient
local Brightness = Lighting.Brightness
local GlobalShadows = Lighting.GlobalShadows
local ClockTime = Lighting.ClockTime
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
if key == "q" then
Ambient = Color3.new(0,0,0)
Brightness = 0
GlobalShadows = true
ClockTime = 0
end
end)
You’re just assigning the value of the properties to variables, it isn’t an actual reference to the property, it’s just storing its value as a variable. You have to index the object for its properties if you want to change them:
Also you should switch to UserInputService for handling inputs, mouse.KeyDown is deprecated meaning if it breaks at some point, it won’t be maintained. UserInputService also offers much more customizability.
my bad about the mouse.KeyDown. I’m not that very good at scripting and very unfamiliar with other things. Anyways, I switched to UserInputService and I feel much better now.