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

Idk the problem is it i need to connect to health changed then check if its =< 0?

Asked by 6 years ago
Edited 6 years ago

this is a jump counter on the leaderboard.

     idk what's wrong with it.
local Players = game.Players

local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'

Instance.new('IntValue', Template).Name = "Jumps"


Players.PlayerAdded:connect(function(Player)
    wait(1)
    local Stats = Template:Clone()
    Stats.Parent = Player
    local jumps = Stats.Deaths
    Player.CharacterAdded:connect(function(Character)
        jumps.Value = jumps.Value + 1
        local Humanoid = Character:FindFirstChild "Humanoid"
        if Humanoid then
            Humanoid.Died:connect(function()
                for i, Child in pairs(Humanoid:GetChildren()) do
                    if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
                        local Killer = Child.Value
                        if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "jumps" then
                            local jumps = jumps.leaderstats.jumps
                            jumps.Value = jumps.Value + 1
                        end
                        return
                    end
                end
            end)
        end
    end)
end)    



0
Please use the code block feature on your code to make it easier to read. RayCurse 1518 — 6y
0
How? XxflamefirewheelXx -10 — 6y
0
Done! XxflamefirewheelXx -10 — 6y
0
One problem is the fact that you made your leaderstats instance a bool value while it should be a model. RayCurse 1518 — 6y
View all comments (2 more)
0
So I should do local Template = Instance.new '?' XxflamefirewheelXx -10 — 6y
0
local Template = Instance.new”Model” should work. RayCurse 1518 — 6y

Answer this question