Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Not Fixed]Legendary Crate Only it wont change to any other crate Help?

Like when I get to 5% it gives me my opening which then shows me legendary crates all the time I tried it like 6 times and got legendary crate I'm thinking it's because the math.random to the #of clones I think because the number of clones is 6 and I have else if c == 6 then legendary not sure please Help

 crates = game.ServerStorage.Crates
 commonclone = crates.Common:Clone()
uncommonclone = crates.Uncommon:Clone()
Rareclone = crates.Rare:Clone()
 Ultrarareclone = crates.Ultrarare:Clone()
 Epicclone = crates.Epic:Clone()
 Legendaryclone = crates.Legendary:Clone()
clones = {commonclone,uncommonclone,Rareclone,Ultrarareclone,Epicclone,Legendaryclone}
c = clones[math.random(#clones)]
plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
	local check1 = plr:WaitForChild("leaderstats")
	if check1 then
		local Percent = check1:WaitForChild("Percent")
		if Percent then
			Percent.Value = Percent.Value + 1
			 local Amount = plr.PlayerGui.CaseClicker.CaseClicker2.Search
			Amount.Text = "Search For Crates : "..tostring(Percent.Value)..tostring("%")
			if Percent.Value == 5 then
				Percent.Value = 0
				plr.PlayerGui.Chooser.Slots.Visible = true
				if c == 1 then
					commonclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
					 else if c == 2 then
						uncommonclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
						else if c == 3 then
							Rareclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
							else if c ==4 then
								Ultrarareclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
								else if c == 5 then
									Epicclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
									else if c == 6 then
										Legendaryclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
									end
								end
							end
						end
					end
				end
				c.Parent = plr.PlayerGui.Chooser.Slots.Slot1
			end
		end
	end
	wait(1)
end)

1 comment

0

Well, it's telling you that it can't find what the length of "choice" is on line 9 (#choice). You never told it what "choice" is before then, so your script has no idea what it is and can't get the length of nothing.

1 answer

Line nine you accidentally put #choice instead of #clones

Here is your fixed script:

 crates = game.ServerStorage.Crates
 commonclone = crates.Common:Clone()
uncommonclone = crates.Uncommon:Clone()
Rareclone = crates.Rare:Clone()
 Ultrarareclone = crates.Ultrarare:Clone()
 Epicclone = crates.Epic:Clone()
 Legendaryclone = crates.Legendary:Clone()
clones = {commonclone,uncommonclone,Rareclone,Ultrarareclone,Epicclone,Legendaryclone}
choice = clones[math.random(#clones)]
plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
    local check1 = plr:WaitForChild("leaderstats")
    if check1 then
        local Percent = check1:WaitForChild("Percent")
        if Percent then
            Percent.Value = Percent.Value + 1
             local Amount = plr.PlayerGui.CaseClicker.CaseClicker2.Search
            Amount.Text = "Search For Crates : "..tostring(Percent.Value)..tostring("%")
            if Percent.Value == 5 then
                Percent.Value = 0
                plr.PlayerGui.Chooser.Slots.Visible = true
                if choice == 1 then
                    commonclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
                     else if choice == 2 then
                        uncommonclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
                        else if choice == 3 then
                            Rareclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
                            else if choice ==4 then
                                Ultrarareclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
                                else if choice == 5 then
                                    Epicclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
                                    else if choice == 6 then
                                        Legendaryclone.Parent = plr.PlayerGui.Chooser.Slots.Slot1
                                    end
                                end
                            end
                        end
                    end
                end
                choice.Parent = plr.PlayerGui.Chooser.Slots.Slot1
            end
        end
    end
    wait(1)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.