Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited by JesseSong 3 years ago

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)
0
Fixed code block JesseSong 3916 — 3y
0
When making answers/questions you need to be more descriptive! JesseSong 3916 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

idk but try "local result = false"

0
Ok Ill try it KEVINRUANO 12 — 3y
0
I removed the game.ReplicatedStorage.Interactions.Server.BuyShopItem:InvokeServer(script.Parent.Case.Value), and put false and it still didn't work. KEVINRUANO 12 — 3y
0
What kind of answer is that? JesseSong 3916 — 3y
Ad
Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago

"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)

Answer this question