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

How to make a player points on kill script?

Asked by
Orptic 5
10 years ago

I am recreating sfoth and I want to add player points I have tried various free models and editing them but none seem to help, this is one of the scripts I took and edited I'm not very good at scripting and I hope someone can tell me what I'm doing wrong so that I myself can finish the game and I can learn something: local numKos = 1 local numPoints = 50 local pointsService = game:GetService("PointsService")

function run(new) repeat wait() print("waiting for leaderboard..") until new:FindFirstChild("leaderstats") and new.leaderstats:FindFirstChild("KOs") kos = new.leaderstats.KOs

01kos.Changed:connect(function(prop)
02 
03    print("Updated: ", prop, "; mult (50 = award):", kos.Value % numKos, "kos:", kos.Value)
04    if (tostring(prop) == "Value" or prop == kos.Value) and (kos.Value % numKos == 1) and (kos.Value ~= 0) then
05        awardable_points = pointsService:GetAwardablePoints()
06        if awardable_points < numPoints then
07            print("Not enough points in the budget");
08        else
09            pointsService:AwardPoints(new.userId, numPoints)
10        end
11    end
12end)

end

game.Players.PlayerAdded:connect(function(new) run(new) end) I also have the script for the leader board I'm using if that helps at all?

print("LinkedLeaderboard script version 5.00 loaded")

stands = {} CTF_mode = false

function onHumanoidDied(humanoid, player) local stats = player:findFirstChild("leaderstats") if stats ~= nil then local deaths = stats:findFirstChild("Wipeouts") deaths.Value = deaths.Value + 1

1    local killer = getKillerOfHumanoidIfStillInGame(humanoid)
2 
3    handleKillCount(humanoid, player)
4end

end

function onPlayerRespawn(property, player)

1if property == "Character" and player.Character ~= nil then
2    local humanoid = player.Character.Humanoid
3        local p = player
4        local h = humanoid
5        humanoid.Died:connect(function() onHumanoidDied(h, p) end )
6end

end

function getKillerOfHumanoidIfStillInGame(humanoid)

01local tag = humanoid:findFirstChild("creator")
02 
03 
04if tag ~= nil then
05 
06    local killer = tag.Value
07    if killer.Parent ~= nil then
08        return killer
09    end
10end
11 
12return nil

end

function handleKillCount(humanoid, player) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil then local stats = killer:findFirstChild("leaderstats") if stats ~= nil then local kills = stats:findFirstChild("KOs") if killer ~= player then kills.Value = kills.Value + 1

1        else
2            kills.Value = kills.Value - 1
3 
4        end
5    end
6end

end


function findAllFlagStands(root) local c = root:children() for i=1,#c do if (c[i].className == "Model" or c[i].className == "Part") then findAllFlagStands(c[i]) end if (c[i].className == "FlagStand") then table.insert(stands, c[i]) end end end

function hookUpListeners() for i=1,#stands do stands[i].FlagCaptured:connect(onCaptureScored) end end

function onPlayerEntered(newPlayer)

01if CTF_mode == true then
02 
03    local stats = Instance.new("IntValue")
04    stats.Name = "leaderstats"
05 
06    local captures = Instance.new("IntValue")
07    captures.Name = "Captures"
08    captures.Value = 0
09 
10 
11    captures.Parent = stats
12 
13 
14    while true do
15        if newPlayer.Character ~= nil then break end
View all 53 lines...

end

function onCaptureScored(player)

1local ls = player:findFirstChild("leaderstats")
2if ls == nil then return end
3local caps = ls:findFirstChild("Captures")
4if caps == nil then return end
5caps.Value = caps.Value + 1

end

findAllFlagStands(game.Workspace) hookUpListeners() if (#stands > 0) then CTF_mode = true end game.Players.ChildAdded:connect(onPlayerEntered)

0
Thanks iDev Orptic 5 — 10y

1 answer

Log in to vote
-1
Answered by 10 years ago

What I would suggest is look at some other pp scripts and see which one works and then edit it to your standards

Ad

Answer this question