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
01 | kos.Changed:connect( function (prop) |
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" ); |
09 | pointsService:AwardPoints(new.userId, numPoints) |
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) |
3 | handleKillCount(humanoid, player) |
end
function onPlayerRespawn(property, player)
1 | if property = = "Character" and player.Character ~ = nil then |
2 | local humanoid = player.Character.Humanoid |
5 | humanoid.Died:connect( function () onHumanoidDied(h, p) end ) |
end
function getKillerOfHumanoidIfStillInGame(humanoid)
01 | local tag = humanoid:findFirstChild( "creator" ) |
06 | local killer = tag.Value |
07 | if killer.Parent ~ = nil then |
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
2 | kills.Value = kills.Value - 1 |
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)
01 | if CTF_mode = = true then |
03 | local stats = Instance.new( "IntValue" ) |
04 | stats.Name = "leaderstats" |
06 | local captures = Instance.new( "IntValue" ) |
07 | captures.Name = "Captures" |
11 | captures.Parent = stats |
15 | if newPlayer.Character ~ = nil then break end |
19 | stats.Parent = newPlayer |
23 | local stats = Instance.new( "IntValue" ) |
24 | stats.Name = "leaderstats" |
26 | local kills = Instance.new( "IntValue" ) |
30 | local deaths = Instance.new( "IntValue" ) |
31 | deaths.Name = "Wipeouts" |
39 | if newPlayer.Character ~ = nil then break end |
43 | local humanoid = newPlayer.Character.Humanoid |
45 | humanoid.Died:connect( function () onHumanoidDied(humanoid, newPlayer) end ) |
48 | newPlayer.Changed:connect( function (property) onPlayerRespawn(property, newPlayer) end ) |
51 | stats.Parent = newPlayer |
end
function onCaptureScored(player)
1 | local ls = player:findFirstChild( "leaderstats" ) |
2 | if ls = = nil then return end |
3 | local caps = ls:findFirstChild( "Captures" ) |
4 | if caps = = nil then return end |
5 | caps.Value = caps.Value + 1 |
end
findAllFlagStands(game.Workspace)
hookUpListeners()
if (#stands > 0) then CTF_mode = true end
game.Players.ChildAdded:connect(onPlayerEntered)