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 9 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:

01game.Players.PlayerAdded:connect(function(player)
02    local stats = Instance.new("IntValue")
03    stats.Name = "leaderstats"
04    stats.Parent = player
05 
06    local experience = Instance.new("IntValue")
07    experience.Name = "Experience"
08    experience.Value = 10
09    experience.Parent = stats
10 
11    local cash = Instance.new("IntValue")
12    cash.Name = "Cash"
13    cash.Value = 500
14    cash.Parent = stats
15 
View all 24 lines...

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.

01function handleKillCount(humanoid, player) -- Calling the function
02    local killer = getKillerOfHumanoidIfStillInGame(humanoid) -- Finding the killer.
03    if stats ~= nil then
04        local stats = killer:findFirstChild("leaderstats")
05        if stats~nil then
06            local kills = leaderstats:findFirstchild("Kills")
07        local cash = leaderstats:findFirstChild("Cash")
08            if killer ~= player then
09                kills.Value = kills.Value + 1  -- Adding a kill to the leaderboard.
10    cash.Value = cash.Value  + 150  -- Amount of money earned per kill
11 
12        else
13            kills.Value = kills.Value - 0
14        end
15        Send_DB_Event_Kill(killer, player)
16    end
17end
18end
19 
20game.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.

01plr = game.Players.LocalPlayer
02medkit = game.Lighting.Medkit:clone()
03 
04script.Parent.MouseButton1Click:connect(function()
05    local v = plr.leaderstats.Cash
06    if v.Value>= 250 then
07        medkit.Parent = plr.Backpack
08        v.Value = v.Value-250
09    end
10end)

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