local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local playercharacter = player.Character
local playerid = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.userId
local money = player:FindFirstChild("Money")
local price = script.Parent.Price.Value
local text = script.Parent.Text
local amo = script.Parent.Ammo.Value
local gun = player.Backpack:FindFirstChild("Peacekeeper") or playercharacter:FindFirstChild("Peacekeeper")
script.Parent.MouseButton1Click:connect(function()
if money.Value >= price then
gun.StoredAmmo.Value = gun.StoredAmmo.Value + 40
money.Value = money.Value - price
elseif money.Value < price then
script.Parent.Text = "You Dont Have Enough Money!"
wait(2)
script.Parent.Text = text
end
end)
this script is in startergui when the game starts it moves to playergui. in the out put this error shows 23:26:57.933 - Players.Player1.PlayerGui.ShopGui.Background.AmmoFrame.PeacekeeperAmmo.Revolver Ammo 40.Script:12: attempt to index upvalue 'gun' (a nil value) 23:26:57.933 - Stack Begin 23:26:57.934 - Script 'Players.Player1.PlayerGui.ShopGui.Background.AmmoFrame.PeacekeeperAmmo.Revolver Ammo 40.Script', Line 12 please help someone

1 comment
May you fix your formatting and explain more about what your trying to do