Im making a script that makes your screen dark when you walk into a room and makes your screen bright when your outside. It works fine, but for some reason it only works once help pls?
Main = script.Parent
Mask = Main.Mask
Mask1 = Main.Mask1
player = game.Players.LocalPlayer
mouse = player:GetMouse()
while wait() do
local ray = Ray.new(
Vector3.new(player.Character.Head.Position),
Vector3.new(0, 900, 0)
)
local part, endPoint = Workspace:FindPartOnRay(ray)
if part then
Mask.BackgroundTransparency = 1
Mask1.BackgroundTransparency = 0.8
elseif not part then
Mask.BackgroundTransparency = 0.8
Mask1.BackgroundTransparency = 1
end
end

2 comments
Is there any errors?
no, I found out that it is becase parts in the Player dont change position, So the reason its happening once is because the ray is only happening in one spot, which is the spot the player spawns in.