What I have so far: workspace.Temp.Current.Value=(0+1) wait(1.5)
script.Parent.MouseClick:connect(OnClicked) I need this because I am working on a core, but I need a certain temperature for the cord to blow up. But I don't want it to go down when it is toggled off.
Here is another script, I want the number to go down:
workspace.Temp.Current.Value=(0-1) wait(3.5) Nothing is working out for me so could someone please help me? ):
For this, you should make a BoolValue object so you can toggle it's Value Property.
Once a BoolValue is setup, you can use the Changed
event to add points when its true. You can put this in ServerScriptStorage.
local toggleVal = game.ServerStorage.BoolValue --Your BoolValue local lastVal = false --The previous state of the BoolValue local Val = workspace.Temp.Current --The value to increase toggleVal.Changed:Connect(function(change) --Changed event if change ~= lastVal then --If the change is different from the lastval lastVal = change; while lastVal and wait(1) do --While it is toggled val.Value = val.Value + 1; --Increase the value end end end)
Now, have a Script inside the Button that uses the MouseClick
function on a ClickDetector object. Make this toggle the BoolValue.
local toggleVal = game.ServerStorage.BoolValue --Your BoolValue script.Parent.MouseClick:Connect(function() --MouseClick event toggleVal.Value = not toggleVal.Value --Toggle the value end)
Maybe make a boolvalue and do ifelse to check if it was pressed like
funtion OnClicked () if OnOrOff == false then --On Or Off means the BoolValue --What you Want OnOrOff = ture elseif OnOrOff == true then --TheToogle OnOrOff = false end
script.Parent.MouseClick:connect(OnClicked)