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

Im getting a attempt to get nil value as an output?

Asked by 6 years ago

Im trying to get a value of a StringValue but keeps saying in the output " 22:47:37.989 - Players.dizzyjamison08.PlayerGui.Shop.Stats.TextButton.LocalScript:6: attempt to index a nil value" im using filtering enabled and the values not nil, i checked. heres the script

axe = script.Parent.Parent.Axe.Value

script.Parent.MouseButton1Click:Connect(function(player)
    if game.Players.LocalPlayer.leaderstats.Bux.Value >= script.Parent.Parent.Pricie.Value then
        print("Not Poor")
        local equip = game.Lighting:FindFirstChild(axe):Clone()
        equip.Parent = game.Players.LocalPlayer.Backpack
    end
end)
0
Please do not use Lighting for storage. That is not what the service is for. You also do realise that MouseButton1Click does not give you the player who clicked the button, right? It wouldn't make sense for it to either, and exploiters can easily abuse the fact that you are doing this all from a localscript User#24403 69 — 6y

1 answer

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Your issue is being caused because axe doesn’t have a value, therefore whilst indexing an object using axe‘s StringValue as a reference, it will come out as nil, since it’s indexing for nothing

0
what does axe =? Ziffixture 6913 — 6y
0
lvl1 dizzyjamison08 30 — 6y
0
If axe’s value is set by another Script, it may not be set before this Script runs, so just add a wait() somewhere usually at the top to fix that Ziffixture 6913 — 6y
Ad

Answer this question