Hello, I’m currently trying to make a farming game. I’m trying to make a sell system with proximity prompts using leaderstats, it works fine, however changing the intValue to a higher number than the set one doesnt seem to do anything? It just reverts back to it’s original value after selling.
Leaderstats
local Players = game:GetService("Players")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Value = 0
Money.Parent = leaderstats
local Wheat = Instance.new("IntValue")
Wheat.Name = "Wheat"
Wheat.Value = 5
Wheat.Parent = leaderstats
end
Players.PlayerAdded:Connect(leaderboardSetup)
Script
local Prompt = script.Parent
Prompt.Triggered:Connect(function(Player)
local Money = Player.leaderstats.Money
local Wheat = Player.leaderstats.Wheat
if Wheat.Value >= 1 then
Money.Value += 1
Wheat.Value -= 1
end
if Wheat.Value == 0 then
print("no")
end
end)
Any help is appreciated.