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

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

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)

1 comment

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

1 answer

✓ Accepted answer

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

3 comments

0

what does axe =?

0

lvl1

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

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