Hello and thank you for reading this.
Currently, right now I have a script that lets you convert the value of a leader stat “egg” into the value of a leader stat “child”. This is done through leaderboards and the code is working just fine. I have a “sell” part you have to touch that makes the leader stat value of “Egg” change over to “Children”, however, if the player has, for example, 2 eggs, and goes to touch the part to convert them, it only gives them +1 children and not +2. Basically, I want to make it so that however many eggs the player has, it’ll convert them into that many children. How can I do this?
Here’s the code that I have which is a script in the “sell” part (Any help would be greatly appreciated!):
local part = script.Parent
local function collect(otherpart)
local player = game.Players:FindFirstChild(otherpart.Parent.Name)
if player then
local playerEggs = player.leaderstats.Eggs.Value
if playerEggs > 0 then
player.leaderstats.Eggs.Value = 0
player.leaderstats.Children.Value = player.leaderstats.Children.Value + 1
end
end
end
part.Touched:Connect(collect)

