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

What does the script mean when it says "interval is empty"?

I was working on a random loot box system I had it working, but when I got back on I stopped working and said this in the output "ServerScriptService.InteractionHandlers.BuyShopItem:39: invalid argument #2 to 'random' (interval is empty) - Client - Purchaser:17"

local plr = game.Players.LocalPlayer

local debounce = false
script.Parent.MouseButton1Click:connect(function()
	
	-- Prevent multiple clicks
	if not debounce then
		debounce = true
		
		-- Play sound
		plr.PlayerGui.GUIClick:Play()
		
		-- Send message to server to purchase
		script.Parent.Text = ". . ."
		local result = game.ReplicatedStorage.Interactions.Server.BuyShopItem:InvokeServer(script.Parent.Case.Value)
		
		-- Show result
		script.Parent.Text = result
		if result == "SUCCESS" then
			script.Parent.Parent.Parent.Visible = false
		elseif result == "CAN'T AFFORD" then
			plr.PlayerGui.MainGui.Shop.PurchaseFail.TimePosition = 0.4
			plr.PlayerGui.MainGui.Shop.PurchaseFail:Play()
			plr.PlayerGui.MainGui.BuyCoins.Visible = true
			plr.PlayerGui.MainGui.BuyCoins.CameFromShop.Value = true
			plr.PlayerGui.MainGui.Shop.Visible = false
			script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0)
		else
			plr.PlayerGui.MainGui.Shop.PurchaseFail.TimePosition = 0.4
			plr.PlayerGui.MainGui.Shop.PurchaseFail:Play()
			script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0)
			wait(2)
		end
		script.Parent.Text = "BUY"
		script.Parent.TextColor3 = Color3.fromRGB(255, 255, 255)
		
		debounce = false
	end
	
end)

2 comments

0

Fixed code block

0

When making answers/questions you need to be more descriptive!

2 answers

idk but try "local result = false"

3 comments

0

Ok Ill try it

0

I removed the game.ReplicatedStorage.Interactions.Server.BuyShopItem:InvokeServer(script.Parent.Case.Value), and put false and it still didn't work.

0

What kind of answer is that?

"interval is empty" error occurs when you try to generate random number between min and max where min is bigger than the max, this does not make sense, right. Your error is thrown on the server where BuyShopItem is processed, remote functions will by default also throw error on client that invoked it. From error you can say that it's script "ServerScriptService.InteractionHandlers.BuyShopItem" on line 39, I can't see your script so look for mistakes such as these:

math.random(-50) -- interval is empty (tried to generate random number from 0 to -50, correctly it should be from - 50 to 0)
math.random(0, -50) -- equal to the previous example
math.random(-50, 0) -- this is correct, min is 50 and max is 0
math.random(200, 150) -- interval is empty (min is 200 and max is 150, nonsense)

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