How do I make my custom leaderstats work in my tycoon?

I am a new developer and I need help to make my leaderstats go up whenever they buy buttons from the tycoon. I have tried lots of other ways to do this but nothing seems to work. When I use any admin commands it never adds the leaderstats. Here is the script that makes the leaderstats:

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"
	local cash = Instance.new("IntValue", leaderstats)
	cash.Name = module.currencyName

	local level = Instance.new("IntValue", leaderstats)
	level.Name = "Level"
end)

My custom leaderstats is the Level. I have already added the save leaderstats when the player left.

2 Likes

Set the name before you set the parent

I dont think you understand, I need help of making the level leaderstats go up once every button bought.

Well from what you’ve said, making the level leaderstat value go up by +1 once a button is purchased you could edit the button purchase function to include incrementing the value by 1. But if you’re wanting to have it as the level leaderstat value to go up by +1 once EVERY button is bought, I would recommend searching up tycoon rebirth tutorials on youtube.

You’d need to give more information, right now it sounds like you are trying to edit the value on the client. Also don’t use the 2nd argument of Instance.new, set the parent as the last property as it’s more optimized.

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
    leaderstats.Parent = plr

	local cash = Instance.new("IntValue")
	cash.Name = module.currencyName
    cash.Parent = leaderstats

	local level = Instance.new("IntValue")
	level.Name = "Level"
    level.Parent = leaderstats
end)
1 Like

I replaced it with your script and it acts the same way, I cant add the level stat through my script

Can you send a video that it is towards adding a leaderstat each button purchase?

wait(2)
local module = require(script.Parent.Parent.Parent.Parent.Parent.Settings)
local dropInfo = script.Parent.DropperInfo
local tcnInfo = script.Parent.Parent.Parent.TycoonInfo
local drop = script.Parent.Drop2
local mesh = script.Parent:FindFirstChild("CustomDrop2")
if mesh then mesh.Parent = nil end
while true do
	local part
	if mesh then
		part = mesh:Clone()
		part.Parent = workspace.Parts
		part.Transparency = 0
		part.Anchored = false
		part.CanCollide = true
	else
		part = Instance.new("Part", workspace.Parts)
		part.Material = tcnInfo.DropMaterial.Value
		part.BrickColor = BrickColor.new("Institutional white")
	end
	--make size 1,1,1
	part.Size = Vector3.new(0.6, 0.6, 0.6)
	part.CFrame = drop.CFrame
	local value = Instance.new('IntValue', part)
	value.Value = dropInfo.LevelValue.Value
	value.Name = 'Level'
	game.Debris:AddItem(part, module.dropLifeTime)
	wait(dropInfo.DropInterval.Value)
end

This is my test dropping script. It is exactly the same as too the other dropper script just replaced the important things to the level leaderstats. The script is not the problem it is the leaderstats itself. It does not go up and there are no errors

I have finally figured it out! But now I need to make it so the dropper needs to only make the leaderstats to a specific number, not add a number. If you would like to help me on that ill be happy for it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.