generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Award Player Points Script.

Previous Thread :: Next Thread 
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:14 PM
It's meant to award 1 point if you get 5, 10, 15 etc. KOs, for some reason it doesn't work...

local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
for i,v in pairs(Char.Humanoid:GetChildren()) do
if v.Value.leaderstats.KOs.Value > 0 and v.Value.leaderstats.KOs.Value % 5 == 0 then
awardPoint(v.Value)
end
return
end
end)
end)
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:15 PM
for i,v in pairs(Char.Humanoid:GetChildren()) do

You try to loop through all the children of their Humanoid which contains no leaderstats.
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:16 PM
What do I do then?
I didn't make this, someone made it for me on SH.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
26 May 2014 04:21 PM
Change it to Player.leaderstats instead of Char.Humanoid
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:22 PM
local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
for i,v in pairs(Player.leaderstats) do
if v.KOs.Value > 0 and v.KOs.Value % 5 == 0 then
awardPoint(v.Value)
end
return
end
end)
end)
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:22 PM
I think I made this and I think you changed it.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
26 May 2014 04:23 PM
I didn't say remove :GetChildren...
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:25 PM
@Free, yeah, I think you did, I editted it because you were awarding 1 KO, as well as my leaderboard, so it was awarding double the KOs.
@War, Ok, I'll fix it.
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:27 PM
local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
Char.Died:connect(function()
local killer = Char:FindFirstChild("creator")
if killer and killer.Value and killer.Value.Parent and killer:FindFirstChild("leaderstats") and killer.leaderstats:FindFirstChild("KOs") then
killer.Value.leaderstats.KOs.Value = killer.Value.leaderstats.KOs.Value+1
if killer.leaderstats.KOs.Value%5 == 0 then
awardPoint(killer.Value)
end
end
end)
end)
local leaderstats = Instance.new("Model", Player)
leaderstats.Name = "leaderstats"

local kills = Instance.new("IntValue", leaderstats)
kills.Name = "KOs"
end)
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:28 PM
That should work if you have a script that creates a leaderstats model then you'll want to delete it. If you want the script to use a leaderstats script you already have then I'll have to change it.
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:30 PM
But would this work:

local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
for i,v in pairs(Player.leaderstats:GetChildren()) do
if v.KOs.Value > 0 and v.KOs.Value % 5 == 0 then
awardPoint(v.Value)
end
return
end
end)
end)
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:31 PM
No.
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:32 PM
Could you make it work with that way?
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:33 PM
In what way?
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:33 PM
Without adding 1 KO.
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:34 PM
Well then how do you expect the Player to gain kills?
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:35 PM
Using the LinkedLeaderboard, the one that ROBLOX made.
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:36 PM
local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
Char.Died:connect(function()
local killer = Char:FindFirstChild("creator")
if killer and killer.Value and killer.Value.Parent and killer:FindFirstChild("leaderstats") and killer.leaderstats:FindFirstChild("KOs") then
if killer.leaderstats.KOs.Value%5 == 0 then
awardPoint(killer.Value)
end
end
end)
end)
end)
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
26 May 2014 04:36 PM
Ok, do you want to try it with me?
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:37 PM
Sure invite me to a party.
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 04:49 PM
local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
Char:WaitForChild("Humanoid").Died:connect(function()
if Char:FindFirstChild("Humanoid") then
local killer = Char.Humanoid:FindFirstChild("creator")
if killer and killer.Value and killer.Value.Parent and killer:FindFirstChild("leaderstats") and killer.leaderstats:FindFirstChild("KOs") then
if killer.leaderstats.KOs.Value%5 == 0 then
awardPoint(killer.Value)
end
end
end
end)
end)
end)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
26 May 2014 04:50 PM
FSM, why did you remove the check if KOs > 0...
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
26 May 2014 05:05 PM
local PointsService = Game:GetService("PointsService")

function awardPoint(Player)
if PointsService:GetAwardablePoints() > 0 then
PointsService:AwardPoints(Player.userId, 1)
end
end

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Char)
Char:WaitForChild("Humanoid").Died:connect(function()
if Char:FindFirstChild("Humanoid") then
local killer = Char.Humanoid:FindFirstChild("creator")
if killer and killer.Value and killer.Value.Parent and killer:FindFirstChild("leaderstats") and killer.leaderstats:FindFirstChild("KOs") and killer.leaderstats.KOs.Value > 0 then
if killer.leaderstats.KOs.Value%5 == 0 then
awardPoint(killer.Value)
end
end
end
end)
end)
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image