You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want to make a loop run however many times the number value is, without changing the value.
What is the issue? I have no clue what to do.
What solutions have you tried so far? I looked it up multiple different ways but I couldn’t find what I was looking for.
while wait(0.5) do
for i,plr in pairs(game.Players:GetChildren()) do
ammountofjump = plr.Potions.JumpPotions
if plr.team == game.Teams.Playing then
print("Playing")
if ammountofjump.Value >= 1 then
wait(1)
local jumpclone = game.ServerStorage.Potions.JumpPotion:Clone()
jumpclone.Parent = plr.Backpack
ammountofjump.Value = ammountofjump.Value - 1
end
end
end
I am making a round based game, and I made a number value that is named JumpPotions. The value of it is how many jump potions the player has. Im kinda making a inventory system. But if I add a script that saved progress, if they leave while the game is running the value will be zero and they will save with no potions. Now I need to figure out how I do what was listed in the title.
have you tried adding another value and copying the new value’s value to the first value’s value, then you can change the value of the 2nd one instead?
wait im a bit confused: are you trying to go from 0 to the first value’s value?
or: are you trying to count the amount of loops it does?
or: are you trying to loop the amount of times the first value’s value?
So basically, you can buy a potion from the shop, then the value of it goes up, then it gives you that many potions that the value has once the round starts.
If you can customize this to your script, it does work for me
local Value = game.Workspace:FindFirstChild("Value").Value
for count = 1, Value do
print("Looping... Goal: "..Value.." times")
end
wait()
print("Finished!")
Value = 0
Mine happens literally instantly, to add delay do:
local Value = game.Workspace:FindFirstChild("Value").Value
for count = 1, Value do
print("Looping... Goal: "..Value.." times")
wait(1)
end
wait()
print("Finished!")
Value = 0
No problem, change it to this though. Found an error resetting it to 0
local Value = game.Workspace:FindFirstChild("Value")
for count = 1, Value.Value do
print("Looping... Goal: "..Value.Value.." times")
wait(1)
end
wait()
print("Finished!")
Value.Value = 0
Basically now the variable is just the value itself, then doing .Value to get it’s value