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

Math.random error, interval is empty?

Asked by 4 years ago

"Workspace.Wood Crate.Script:14: bad argument #1 (interval is empty)"

local serverStorage = game:GetService("ServerStorage")
local players = game:GetService("Players")

local weapons = serverStorage.Weapons:GetChildren()

local loot = script.Parent
local part = loot.PrimaryPart

part.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
    if (humanoid and humanoid.Health > 0) then
        local player = players:GetPlayerFromCharacter(hit.Parent)
        local backpack = player:WaitForChild("Backpack")
        local clonedWeapon = weapons[math.random(#weapons)]:Clone()
        clonedWeapon.Parent = backpack
        loot:Destroy()
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

It's now solved. If this happens to you, just make sure the items are in the referenced place. Like I forgot that the weapons are not in the Weapons folder. :)

Ad

Answer this question