Idk if asking another question is allowed but I forgot to add this lol,
I'm making a repeating script that always sets the value down by 1 every 3 seconds and keeps going down but for some reason, it won't work. then when the value reaches 0. a pathfinding system for a bot activates
local Number = script.Parent.Value local saliAI = workspace.AI.Sali.pathfind if true then Number.Value = Number.Value - 1 wait(3) end if Number.Value == 0 then saliAI.Enabled = true end
also there is a proximity point that when done, it adds 5 to the current number in the timer / value. also i need it to stop from going above 100
local ProximityPrompt = script.Parent local Number = script.Parent.Parent.Parent.Value ProximityPrompt.Triggered:Connect(function(player) Number.Value = Number.Value + 5 end)
i hope this isn't too much to ask
You can use loops (such as while
, repeat
, and for
) to repeat a specific line of code. Make a condition whether the number is more than 0 or not. If not, it will enable the pathfinidng ai and break the script. It's simple as that. You don't have to change something in the proximity prompt script.
local Number = script.Parent.Value local saliAI = workspace.AI.Sali.pathfind while task.wait(3) do -- will repeat every 3 seconds if Number.Value > 0 then -- if it's more than zero Number.Value -= 1 -- decreases it by 1 else -- if 0 saliAI.Enabled = true -- enables it break -- stopping the loop forever end end
Proximity Prompt Script:
local ProximityPrompt = script.Parent local Number = ProximityPrompt.Parent.Parent.Value ProximityPrompt.Triggered:Connect(function(player) Number.Value += 5 -- adds 5 end)