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

Cannot understand this error "leaderstats is not a valid member of PlayerGui" Please help?

Asked by 4 years ago

So uh yeah this is the code

player = script.Parent.Parent.Parent.Parent.Parent.Parent
money = player.leaderstats.Cash 
price = 100 
tool = game.Lighting.ShopItems:findFirstChild("M16A4")


function buy()
if money.Value >= price then
money.Value = money.Value - price
local a = tool:clone()
a.Parent = player.Backpack
--local b = tool:clone()   [in case I want a tool to save on death]
--b.Parent = player.StarterGear

end
end
script.Parent.MouseButton1Down:connect(buy)

And here is the error in the output

03:23:04.352 - leaderstats is not a valid member of PlayerGui 03:23:04.353 - Stack Begin 03:23:04.353 - Script 'Players.MaximusFireFight.PlayerGui.Shop.weaponshop.Desc.M16A4Description.Purchase.Main', Line 4 03:23:04.354 - Stack End

I have no idea what it means by leaderstats not being a valid member of the PlayerGui, any help would be much appreciated, thanks UwU

0
Your stack trace is cut off so it's hard to tell from that, but it seems likely that in line 1 you need one more parent as player is referencing PlayerGui rather than player, so that when you have player.leaderstats.Cash on the next line it's trying to find leaderstats in PlayerGui vector3_zero 1056 — 4y
0
Thanks! You're a god UwU MaximusFireFight -2 — 4y

Answer this question