local PowerValue = workspace.DoorButton.ProximityPrompt.PowerScript.PowerValue.Value
while DoorClosed.Value == true do
wait(0.5)
PowerValue = PowerValue - 10
end
if PowerValue == 0 then
print("Power outage!")
workspace.DoorButton.ProximityPrompt.Enabled = false
end```
Does anybody know what's wrong with this script? The PowerValue never goes down, even if the door is closed, though the power-outage section of the script works. I've been unable to figure out how to get int/number values to go up or down, any help would be appreciated!
#Unable to change an intvalue in my script
1 messages · Page 1 of 1 (latest)
Doing local PowerValue = workspace.DoorButton.ProximityPrompt.PowerScript.PowerValue.Value only makes a new variable called "PowerValue" with for its value, the value of your IntValue when you set the variable.
You just have to move .Value.
local DoorClosed = workspace.DoorButton.ProximityPrompt.DoorScript.DoorClosed;
local PowerObj = workspace.DoorButton.ProximityPrompt.PowerScript.PowerValue
while DoorClosed.Value == true do
wait(0.5)
PowerObj.Value -= 10
end
if PowerObj.Value == 0 then
print("Power outage!")
workspace.DoorButton.ProximityPrompt.Enabled = false
end
@inland cloak
Ok I'm trying this now to make sure it works
Ok
I copied your script in the place of the old one, but the value still isn't going down, even if DoorClosed is true
Nope. I've been trying to do even more basic intvalue scripts and nothing I try can change a value
Ok I'm gonna try it
I can make it decrease ._.
Something must be wrong with your instances or with the Value of DoorClosed
** You are now Level 1! **
It could be, though I don't think there's anything wrong with DoorClosed, as it's true
And everything else related to it works, so maybe instances then
Add a print in between the wait and the value set in the while loop
If nothing prints, the bool gets set to false somewhere
If not, I have no clue
My last idea would be to use NumberValue but I think that makes no difference in your case
I just use way more NumberValues than Ints
Ok I added a print between those lines, and nothing is printing. I watched the DoorClosed bool and it switches as it should when the door opens/closes
I could try a number value and see if that changes anything
Ok I swapped it for a NumberValue and nothing changed
Honestly I'm at a loss, and consistantly every script I put an int/number value into breaks
Ooh I think I get what you want, you want it to run the loop when the door closes?
The way you're doing it rn only checks at start of the game
local DoorClosed = workspace.DoorButton.ProximityPrompt.DoorScript.DoorClosed :: BoolValue
local PowerObj = workspace.DoorButton.ProximityPrompt.PowerScript.PowerValue :: IntValue
local function OnDoorClose()
if DoorClosed.Value then -- Is Closed
repeat
wait(0.5)
PowerObj.Value -= 10
until (not DoorClosed.Value)
end
end
DoorClosed:GetPropertyChangedSignal("Value"):Connect(OnDoorClose)
OnDoorClose()
if PowerObj.Value == 0 then
print("Power outage!")
workspace.DoorButton.ProximityPrompt.Enabled = false
end
Try this
Good, gl fixing the power outage
Alright thanks for the help :)