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

Game script problem help?

Asked by 8 years ago

So I have things on this game pretty close to done but there are 2 things missing. If you can take the time to help me with these problems I'd appreciate it(I posted these questions individually yesterday but no one answered) First since everything is linked to the leaderboard, here is my leaderboard script:

game.Players.PlayerAdded:connect(function(player)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    stats.Parent = player

    local experience = Instance.new("IntValue")
    experience.Name = "Experience"
    experience.Value = 10
    experience.Parent = stats

    local cash = Instance.new("IntValue") 
    cash.Name = "Cash"
    cash.Value = 500 
    cash.Parent = stats

    local kills = Instance.new("IntValue")
    kills.Name = "Kills"
    kills.Value = 0
    kills.Parent = stats

    while wait(10) do
    experience.Value = experience.Value +15
end
end)

Now my problem is the kills. I got a script from someone here but it seems like it doesn't quite work..The weapons in my game are the linked sword, a sniper, chaingun(gamepass weapon) and the R-orb.

function handleKillCount(humanoid, player) -- Calling the function
    local killer = getKillerOfHumanoidIfStillInGame(humanoid) -- Finding the killer.
    if stats ~= nil then
        local stats = killer:findFirstChild("leaderstats")
        if stats~nil then
            local kills = leaderstats:findFirstchild("Kills")
        local cash = leaderstats:findFirstChild("Cash")
            if killer ~= player then
                kills.Value = kills.Value + 1  -- Adding a kill to the leaderboard.
    cash.Value = cash.Value  + 150  -- Amount of money earned per kill

        else
            kills.Value = kills.Value - 0
        end
        Send_DB_Event_Kill(killer, player)
    end 
end
end

game.Players.ChildAdded:connect(onPlayerEntered)

If you can help fix the script or give me some help i would greatly appreciate it. Now the 2nd problem would be a in game gui shop.

plr = game.Players.LocalPlayer
medkit = game.Lighting.Medkit:clone()

script.Parent.MouseButton1Click:connect(function()
    local v = plr.leaderstats.Cash
    if v.Value>= 250 then
        medkit.Parent = plr.Backpack
        v.Value = v.Value-250
    end
end)

I am not so sure why that does not work...In Lighting I have the Medkit...Can someone help?

Any help is greatly appreciated. Thanks.

Answer this question