Hello everyone, I recently got into developing, and I’m not so good at it…
I am making a game where you have a factory that is powered by steam, steam uses water, so i’m trying to make a thing for that so the water slowly decreases, but I’ve got a problem.
There’s a valve that you’d need to click to open it and let the water enter the boiler.
Usually, my developing friend helps me, but he’s on a trip right now, making him unavailable for me.
It’s where you click the valve, it would keep on decreasing the water level by 0.001 every time until the valve is clicked again. But here’s the issue: It does not repeat it, and it does not stop when a user clicks(It does not even start in the first place). it’s as if it’s a single click like this:
So I would’ve just did a if else statement instead of that because if else statements can easily be changed
local Click = script.Parent
local Debounce = false
Click.MouseClick:Connect(function()
Debounce = not Debounce
if Debounce then
repeat
-- Put what you want to repeat here
until Debounce == false
else
-- Change whatever when it ends
end
end)
Edit: tested your script too, yours play only once probably because it’s receiving the click signal as well so waiting for a bool to change true/false would work around that issue
so I changed the script a bit for you and you’ll need to define the location of the speed yourself but assuming you’re just using angular velocity
local Click = script.Parent
local Speed = --define location of speed
local Debounce = false
Click.MouseClick:Connect(function()
Debounce = not Debounce
if Debounce then
Speed.AngularVelocity = Vector3.new(10,0,0)
repeat
script.Parent.Parent.Parent.WaterLevel1.Value += -1 / 1000
until Debounce == false
else
Speed.AngularVelocity = Vector3.new()
end
end)
or you can disable the velocitys instead of changing the direction