What do you want to achieve?
I am trying to make the amount of pellets be subtracted by 250 every .25 seconds
What is the issue?
The loop stops whenever the amount of pellets is below the upgradeMod:GetAmountOfPelletsPerDrop() (returns 250)
and outputs an error:
What solutions have you tried so far?
I did my best to see what the problem was but I don’t have a clue
The part of the script where I believe the issue is
--[[line forty five]] pelletAmount.Changed:Connect(function() -- "pelletAmount" is a NumberValue
local amount = pelletAmount.Value
while pelletAmount.Value > 0 do
print('fefe')
if pelletAmount.Value >= upgradeMod:GetAmountOfPelletsPerDrop() --[["upgradeMod:GetAmountOfPelletsPerDrop()" returns 250]] then
print('fer')
pelletAmount.Value -= upgradeMod:GetAmountOfPelletsPerDrop()
script.Parent.Pellets.Size = Vector3.new(pellet.Size.X, perPellet * pelletAmount.Value, pellet.Size.Z) -- the size of this object represents the quantity of pellets
else
pelletAmount = 0
-- more will be added later
end
wait(.25)
end
end)
local amount = pelletAmount.Value
while pelletAmount.Value > 0 do
print('fefe')
if pelletAmount.Value >= upgradeMod:GetAmountOfPelletsPerDrop() --[["upgradeMod:GetAmountOfPelletsPerDrop()" returns 250]] then
print('fer')
pelletAmount.Value -= upgradeMod:GetAmountOfPelletsPerDrop()
script.Parent.Pellets.Size = Vector3.new(pellet.Size.X, perPellet * pelletAmount.Value, pellet.Size.Z) -- the size of this object represents the quantity of pellets
else
pelletAmount.Value = 0
-- more will be added later
end
wait(.25)
end
end)
I put it before the loop but it just gave another error. What I put was:
pelletAmount.Changed:Connect(function() -- "pelletAmount" is a NumberValue
pellet(typeof(pelletAmount))
while pelletAmount.Value > 0 do
print('fefe')
if pelletAmount.Value >= upgradeMod:GetAmountOfPelletsPerDrop() --[["upgradeMod:GetAmountOfPelletsPerDrop()" returns 250]] then
print('fer')
pelletAmount.Value -= upgradeMod:GetAmountOfPelletsPerDrop()
script.Parent.Pellets.Size = Vector3.new(pellet.Size.X, perPellet * pelletAmount.Value, pellet.Size.Z) -- the size of this object represents the quantity of pellets
else
pelletAmount = 0
-- more will be added later
end
wait(.25)
end
end)
local connection
function dothing()
connection:Disconnect()
connection = pelletAmount.Changed:Connect(dothing)
while pelletAmount.Value > 0 do
print('fefe')
if pelletAmount.Value >= upgradeMod:GetAmountOfPelletsPerDrop() --[["upgradeMod:GetAmountOfPelletsPerDrop()" returns 250]] then
print('fer')
pelletAmount.Value -= upgradeMod:GetAmountOfPelletsPerDrop()
script.Parent.Pellets.Size = Vector3.new(pellet.Size.X, perPellet * pelletAmount.Value, pellet.Size.Z) -- the size of this object represents the quantity of pellets
else
pelletAmount.Value = 0
-- more will be added later
end
wait(.25)
end
end
end
connection = pelletAmount.Changed:Connect(dothing)