Error:15:18:16.560 - Players.Player1.PlayerGui.MainShop.MainShop.Frame.Assault R:19: attempt to index global 'GuiButtonPath' (a nil value)
Full script: vvvvvv
local player = game.Players.LocalPlayer --This only works in a local script.
cost = 0 --assign the cost of the AssaultRifle here.
function checkForAssaultRifle()
for i, v in pairs(player.Backpack:GetChildren()) do
if v.Name == "AssaultRifle" then
return true
end
end
for i, v in pairs(player.Character:GetChildren()) do
if v.Name == "AssaultRifle" then
return true
end
end
return false
end
GuiButtonPath.MouseButton1Click:connect(function()
local needsAssaultRifle = not checkForAssaultRifle() --needsAssaultRifle is the opposite of found.
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats ~= nil then
local Money = leaderstats:FindFirstchild("Money")
if Money ~= nil then
if Money.Value >= cost and needsAssaultRifle then --if they have the money and they need a AssaultRifle
Money.Value = Money.Value - cost --subtract cost from funds
AssaultRifle = game.Lighting.AssaultRifle:Clone()
AssaultRifle.Parent = player.Backpack --give them a AssaultRifle
end
end
end
end)
It was working earlier, and I know the cost isn't the problem, it just stopped working after I change the previous items name with 'AssaultRifle'. Thanks!

2 comments
What is wrong with it? And you should be telling US the error. Debug before you come here okay, use output.
15:18:16.560 - Players.Player1.PlayerGui.MainShop.MainShop.Frame.Assault R:19: attempt to index global 'GuiButtonPath' (a nil value)