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

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

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

✓ Accepted answer
--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()

1 comment

0

Thanks, it worked.

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