Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
m2_s0r 2
2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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

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) m2_s0r 2 — 2y
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 AProgrammR 398 — 2y
0
Sorry for the spelling mistakes. I was typing a bit fast, lol AProgrammR 398 — 2y
0
Ok, I have updated the question, you can find the stats script there m2_s0r 2 — 2y
View all comments (2 more)
0
edited my answer AProgrammR 398 — 2y
0
thank you, I think it quite worked..I'll post another comment if I have any troubles m2_s0r 2 — 2y
Ad

Answer this question