I am trying to decrease the value of a player’s fat, but the script just seems to fail and not do anything, even the output has no response on it, besides “leaderstats is not a valid member of player”, but I do not know how to solve this.
Here are some scripts that connect to this
Food Cloning Script:
game.Players.PlayerAdded:Connect(function(player)
local Fat = player.leaderstats.Fat
game.ReplicatedStorage.Burger.OnServerEvent:Connect(function()
if Fat >= 2000 then
local Burger = game.ServerStorage.Tools.Burger:Clone()
Burger.Parent = player.StarterGear
Burger.Parent = player.Backpack
Fat = Fat - 2000
end
end)
-- more code here
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Fat = Instance.new("NumberValue")
Fat.Name = "Fat"
Fat.Parent = leaderstats
local rebirth = Instance.new("IntValue")
rebirth.Name = "Rebirths"
rebirth.Parent = leaderstats
local Fatbux = Instance.new("IntValue")
Fatbux.Name = "Fatbux"
Fatbux.Parent = player
--rest of the code here
`
Tell me if I am wrong, but I am pretty sure that when you set the PlayerAdded Event it refers to the local player that has joined right? And yes I did test it with more then 2000 fat. If anyone could help me on this that would be awesome thanks!