if game.Players.LocalPlayer.leaderstats.Ingredients.Value > 1 then script.Parent.Activated:Connect(function()
local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent) plr.leaderstats.Ingredients.Value = plr.leaderstats.Ingredients.Value -1 plr.leaderstats.Cake.Value = plr.leaderstats.Cake.Value +1
end) end
You have everything you need, but you have placed it in the wrong order. If this is a server script, the local player cannot be accessed. So you must use :GetPlayerFromCharacter, like you did later in the script.
script.Parent.Activated:Connect(function() local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent) if plr.leaderstats.Ingredients.Value >1 then plr.leaderstats.Ingredients.Value = plr.leaderstats.Ingredients.Value -1 plr.leaderstats.Cake.Value = plr.leaderstats.Cake.Value +1 else end end)
Is this in a regular script or local script? If it is server script , LocalPlayer cannot be used.