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

01local serverStorage = game:GetService("ServerStorage")
02local players = game:GetService("Players")
03 
04local weapons = serverStorage.Weapons:GetChildren()
05 
06local loot = script.Parent
07local part = loot.PrimaryPart
08 
09part.Touched:Connect(function(hit)
10    local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
11    if (humanoid and humanoid.Health > 0) then
12        local player = players:GetPlayerFromCharacter(hit.Parent)
13        local backpack = player:WaitForChild("Backpack")
14        local clonedWeapon = weapons[math.random(#weapons)]:Clone()
15        clonedWeapon.Parent = backpack
16        loot:Destroy()
17    end
18end)

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