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

repost of my leaderstat not changing pls help?

Asked by
VipDanT 10
2 years ago
local humanoid = workspace.Dummy:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(script.Parent)

humanoid.Died:Connect(function()
    player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
    player.leaderstats.Levels.Value = player.leaderstats.Levels.Value + 1
end)

why is it not working

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player



    local coins = Instance.new("IntValue")
    coins.Name = "Levels"
    coins.Value = 0
    coins.Parent = leaderstats
end



game.Players.PlayerAdded:Connect(onPlayerJoin)

Same for coins but it's coins

0
What type of script is the first script? JaydenLegenderyDude 22 — 2y
0
normal script in an r15 dummy VipDanT 10 — 2y
0
bottom is a normal script in serverscriptservice VipDanT 10 — 2y
0
Can you explain what you are trying to do theking66hayday 841 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

I don't know if this will work, but I saw that you called the coins levels, so I solved it

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Value = 0
    coins.Parent = leaderstats

    local levels = Instance.new("IntValue")
    levels.Name = "Levels"
    levels.Value = 0
    levels.Parent = leaderstats
end



game.Players.PlayerAdded:Connect(onPlayerJoin)

And you got the character of the player, and not the player, because the leaderstats values is in the player, and not the character, so I solved it as well

local humanoid = workspace.Dummy:FindFirstChild("Humanoid")

humanoid.Died:Connect(function()
    game.Players.PlayerAdded:Connect(function(player)
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
        player.leaderstats.Levels.Value = player.leaderstats.Levels.Value + 1
    end)
end)

I can't confirm if it works because I don't have the dummy, and make sure that both of the Normal Scripts are in ServerScriptService.

0
If you're wondering the dummy is just a normal r15 dummy VipDanT 10 — 2y
Ad

Answer this question