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
Try that, it should work.
Main = script.Parent Mask = Main.Mask Mask1 = Main.Mask1 player = game.Players.LocalPlayer mouse = player:GetMouse() while true do 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 end