Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make it so a certain user's leaderstats in my game stay the same and won't change?

The name of my leaderstats is "Deaths".

this is the leaderstats script:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local lead = Instance.new("Folder")
	lead.Name = "leaderstats"
	lead.Parent = player
	local deaths = Instance.new("IntValue")
	deaths.Name = "Deaths"
	deaths.Parent = lead
	
	player.CharacterAdded:Connect(function(character)
		local hum = character:FindFirstChild("Humanoid")
		hum.Died:Connect(function()
			deaths.Value = deaths.Value +1
		end)
	end)
end)

1 answer

✓ Accepted answer

Try:

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
    local lead = Instance.new("Folder")
    lead.Name = "leaderstats"
    lead.Parent = player
    local deaths = Instance.new("IntValue")
    deaths.Name = "Deaths"
    deaths.Parent = lead

    player.CharacterAdded:Connect(function(character)
        local hum = character:FindFirstChild("Humanoid")
        hum.Died:Connect(function()
            deaths.Value = deaths.Value +1
        end)
    end)
	deaths.Changed:Connect(function()
		if player.Name == 'name here' then  -- Name for which player has the stats stay on
			deaths.Value = number which is stuck on
		end
	end)
end)

Paste it

6 comments

0

I think instead this made everyone's leaderstats stay that same value, where am I supposed to put the script? (sorry, I am new to scripting)

0

Ok, maybe just give me thee stats script by editing you question real quick and then il modify it. You will paste the script inside the stats script. And no, it does for a certain player since it check the player's name

0

Sorry for the spelling mistakes. I was typing a bit fast, lol

0

Ok, I have updated the question, you can find the stats script there

0

edited my answer

0

thank you, I think it quite worked..I'll post another comment if I have any troubles

This discussion is preserved as it was. New answers, comments, and votes are closed.