The purpose of this script is to raise and descend 2 random block in the jumparts model in a continuous loop until there is no more blocks in jumparts to raise, but what it does is raise the same blocks over and over again . I do not get any output errors and yes the debounce code works perfect. The blocks are random at the start but it just keeps raising and descending those 2 random block chosen at the start. Thanks for taking your time to read this post. I was to lazy to make a function for random numbers haha.
jumparts={}
for i,v in pairs(game.Workspace.jumparts:GetChildren())do
table.insert(jumparts,i,v)
end
function ranNum()
local ranNum1=math.random(1,#jumparts)
local ranNum2=ranNum1
while ranNum1==ranNum2 do
ranNum2=math.random(1,#jumparts)
wait()
end
local blockChosen=jumparts[ranNum1]
local blockChosen2=jumparts[ranNum2]
if enabled==true then
enabled=false
script.Parent.BrickColor=BrickColor.new("Really red")
for i,v in pairs(jumparts)do
while true do
for i=4,13,0.3 do
blockChosen.CFrame=CFrame.new(blockChosen.Position.x,blockChosen.Position.y+1.1,blockChosen.Position.z)
blockChosen2.CFrame=CFrame.new(blockChosen2.Position.x,blockChosen2.Position.y+1.1,blockChosen2.Position.z)
wait(0.1)
end
wait(1)
for i=13,4,-0.3 do
blockChosen.CFrame=CFrame.new(blockChosen.Position.x,blockChosen.Position.y-1.1,blockChosen.Position.z)
blockChosen2.CFrame=CFrame.new(blockChosen2.Position.x,blockChosen2.Position.y-1.1,blockChosen2.Position.z)
wait(0.1)
end
table.remove(jumparts,ranNum1)
table.remove(jumparts,ranNum2)
local ranNum1=math.random(1,#jumparts)
local ranNum2=ranNum1
while ranNum1==ranNum2 do
ranNum2=math.random(1,#jumparts)
wait()
end
end
end
end
script.Parent.BrickColor=BrickColor.new("Lime green")
enabled=true
end
enabled=true
function onClicked()
ranNum()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

8 comments
Just supplying code and not an explanation doesn't help anyone learn, please supply an explanation as to why your answer fixed anything.
Do not use the 'Answer' feature to reply to someone, it signifies that someone has Answered your Question! Use the Comments feature of the site, which can be found BELOW your Question or Answer, it's a Rectangular Box which says 'Post a comments...'.
You bastards make up the most stupid rules on this site i cannot have a post without you admins complaining all the time sometimes that "BOX" you are talking about does not show up dont ask me why and i did supply an explanation so stop complaining
this website have some of the most non-frugal thinking minds
We are ALLOWED to Moderate users! Also, the rules are not 'stupid' as you claim, and by your Comment replies, it is breaking some of the rules. Guidelines: https://scriptinghelpers.org/help/community-guidelines How to post good Answers and Questions: https://scriptinghelpers.org/help/how-post-good-questions-answers
Also, when did our Comments ever say anything about the Sites Rules? Because, you brought up that the Rules were 'stupid', when we were telling you Warnings, and heads ups.
great more stupid rules no wonder you dont get alot of visitors
You have already broken Rules 1, 4, and 7 of the Guidelines, please do not use that type of Language.