I am trying to make an inventory system in my game and I am trying to make a thing in a local script inside starter player scripts where it checks if a value has changed and then fires an event to see if they have reached max capacity, and I know this should work because I have done nearly the exact same thing with experience and levels but for some reason when I run the code it gives an error saying "leaderstats is not a member of player" does anyone know whats happening? Here is the code in the local script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:FindFirstChild("InventoryFullEvent")
local player = game.Players.LocalPlayer
local playerBeans = player.leaderstats.Beans
playerBeans.Changed:Connect(function()
Event:FireServer()
end)

1 comment
It works, thank you very much. Looking at my other script with levels and experience I apparently used WaitForChild and didn't notice. Thanks for the answer!