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

How do I fix "attempt to index local 'output' (a number value)?

Asked by 5 years ago

This script randomly assigns a weapon to a player each time they spawn. It seems to work as it should, but I keep getting this error: Players.zhendirez.PlayerScripts.LocalScript:7: attempt to index local 'output' (a number value)

I don't get what the problem is, so if someone can explain it, i'd appreciate it. Here's the LocalScript:

--Thanks to LucarioZombie for this
local weapons = {game.ReplicatedStorage.Weapons["Tool1"], game.ReplicatedStorage.Weapons["Tool2"]}
repeat 
    wait(0.1)
until nil ~= game.Players.LocalPlayer.Character
local output = math.random(1, #weapons)
output.Value:Clone().Parent = game.Players.LocalPlayer.BackPack 
script:Destroy()

(yes, this is a script someone let me use, i'm just trying to troubleshoot it)

1 answer

Log in to vote
1
Answered by
EDLLT 146
5 years ago
--Thanks to LucarioZombie for this
local weapons = {game.ReplicatedStorage.Weapons["Tool1"], game.ReplicatedStorage.Weapons["Tool2"]}
repeat 
    wait(0.1)
until nil ~= game.Players.LocalPlayer.Character
local output = weapons[math.random(1,#weapons)]
output.Value:Clone().Parent = game.Players.LocalPlayer.BackPack 
script:Destroy()
0
Thanks, it worked. zhendirez 2 — 5y
Ad

Answer this question