Alright so basicaly im making a backrooms game in which i got a int value that if its too low, the player die’s. to prevent the player from dying i made a tool. and it has a script but it doesn’t work. i don’t why.
local tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
tool.Equipped:Connect(function()
mouse.Button1Down:Connect(function()
workspace.Script.Brain.Value = workspace.Script.Brain.Value + 50
end)
end)
i noticed a problem. so i also got a script that every 2 seconds the brain.value goes down by 1. but when i activate the tool it just, goes back to normal.
local brain = script.Brain
while true do
wait(2)
brain.Value = brain.Value - 1
if brain.Value == 90 then
game.Lighting.ColorCorrection.Brightness = -0.1
if brain.Value == 80 then
game.Lighting.ColorCorrection.Brightness = -0.2
if brain.Value == 70 then
game.Lighting.ColorCorrection.Brightness = -0.3
if brain.Value == 60 then
game.Lighting.ColorCorrection.Brightness = -0.4
if brain.Value == 50 then
game.Lighting.ColorCorrection.Brightness = -0.5
if brain.Value == 40 then
game.Lighting.ColorCorrection.Brightness = -0.6
end
end
end
end
end
end
end
local brain = script.Brain
while true do
wait(2)
-- Decrease brain value by 1
brain.Value = brain.Value - 1
-- Update lighting brightness based on brain value
local brightnessValue = -0.1 * math.floor((100 - brain.Value) / 10)
game.Lighting.ColorCorrection.Brightness = brightnessValue
if brain.Value <= 0 then
-- Handle the player's death or other consequences here
break -- Exit the loop if brain.Value reaches 0 or below
end
end
look. its goes down and lets say the int’s value is “200” and when i use the tool it becomes 250. but after the 2 seconds i goes down again and becomes 199 instead of 249.