The issue I’m facing is that my shop script isn’t correctly reaching the StinkPoints value inside leaderstats, so the game doesn’t know whether the player has enough points to buy the pet. I need to define what requiredpoints are which is the amount of points you need to buy a pet when you click the textbutton(buybutton) which is the parent of the script. each player has stinkpoints stored in their leaderstats so the stinkpoints don’t reset when they leave.
local buybutton = script.Parent
local player = game.Players.localplayer
local stinkPoints = player:FindFirstChild("leaderstats"):FindFirstChild("StinkPoints")
print("Player's stink points:", stinkPoints.Value)
local requiredpoints = 100
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local stinkPoints = leaderstats:FindFirstChild("StinkPoints")
if stinkPoints then
if stinkPoints.Value >= requiredPoints then
print("You have enough Stink Points to buy this!")
-- Deduct points and grant the pet/item
stinkPoints.Value = stinkPoints.Value - requiredPoints
else
print("Not enough Stink Points! You need at least " .. requiredPoints .. ".")
end
end
end