No, that's not the problem I'm encountering. the if then statement doesn't work because Wall_Hp1 is not defined. I'm trying to make the script set Wall hp to 100 without it setting every time, but can't find how.
local Wall_Hp1 = 100
local Brickwall1 = script.Parent
local click = Brickwall1.ClickDetector
local soundplay = game.Workspace.Brickwall1.Sound
click.MouseClick:Connect(function()
Wall_Hp1 -= 20
print(Wall_Hp1)
if Wall_Hp1 <= 0 then
Wall_Hp1 = 100
end
end)
I may have made a mistake since I didn’t write this in studio but hopefully it should work
Yeah, I've already done that before. The print's outcome is always 80, probably because it's resetting to 100 then subtracting 20. and yes the variable is outside the click function