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
 

Re: Credit Leaderboard Not Working

Previous Thread :: Next Thread 
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:10 PM
I'm using the Cash/KO/WO Leaderboard made by NarutoNumber1. However, it only works for the first person to enter the game. Here's the code :

function onPlayerEntered(newPlayer)


local stats = Instance.new("IntValue")
stats.Name = "leaderstats"

local bounty = 0


local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 0

cash.Parent = stats
stats.Parent = newPlayer

local kills = Instance.new("IntValue")
kills.Name = "KOs"
kills.Value = 0

local deaths = Instance.new("IntValue")
deaths.Name = "Wipeouts"
deaths.Value = 0

kills.Parent = stats
deaths.Parent = stats

while true do
if newPlayer.Character ~= nil then break end
wait(5)
end

local humanoid = newPlayer.Character.Humanoid

humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )

newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )


stats.Parent = newPlayer

end

function Send_DB_Event_Died(victim, killer)
local killername = "unknown"
if killer ~= nil then killername = killer.Name end
print(victim.Name, " was killed by ", killername)

if shared["deaths"] ~= nil then
shared["deaths"](victim, killer)
print("Death event sent.")
end
end

function Send_DB_Event_Kill(killer, victim)
print(killer.Name, " killed ", victim.Name)
if shared["kills"] ~= nil then
shared["kills"](killer, victim)
print("Kill event sent.")
end
end



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

local killer = getKillerOfHumanoidIfStillInGame(humanoid)


Send_DB_Event_Died(player, killer)
handleKillCount(humanoid, player)
end
end

function onPlayerRespawn(property, player)

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

function getKillerOfHumanoidIfStillInGame(humanoid)
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then

local killer = tag.Value
if killer.Parent ~= nil then -- killer still in game
return killer
end
end

return 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
cash = cash.Value + 10
else
kills.Value = kills.Value - 0

end
Send_DB_Event_Kill(killer, player)
end
end
end

game.Players.ChildAdded:connect(onPlayerEntered)

Does anyone know why it only works for the first person to enter? If so, could you tell me how to fix it?
Report Abuse
TomsGames is online. TomsGames
Joined: 11 Oct 2013
Total Posts: 1615
10 Apr 2014 06:14 PM
We generally don't want to read 100+ lines

Please pick out the important bits
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:22 PM
I'm not a professional scripter, sir. I don't know what qualifies as the "important bits".
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
10 Apr 2014 06:23 PM
u didnt make it so no fix it
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:26 PM
Why does it matter if I made it? I need it to work for my place, but I don't know how it works. Can I not ask for help from someone who does understand the Lua scripting language?
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
10 Apr 2014 06:27 PM
no man like lrn2script
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:29 PM
I would, but I have nobody to teach me. As well, I need this help ASAP. It will take a while to learn to script, and I need this fixed before then. If you are so against this fact, then refrain from posting. It's useless to tell me what I already know.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
10 Apr 2014 06:30 PM
dude get a free model or something
nobody is going to do this for you, unless they already have one at ready
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:30 PM
As well, if you dislike this request for help, then leave it be. There's no reason for you to sit here and continually post that I shouldn't ask for help and that I need to "lrn2script". Go troll elsewhere.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
10 Apr 2014 06:31 PM
no i like this thread
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:31 PM
It IS a free model. That's where I acquired it. However, of the 26 others I've tried, none work at all. This is the only script that shows even a trace of proper function. The rest do absolutely nothing. I'm tired of spending all my time repeatedly trying broken scripts, so I am asking for help with the most functional one.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
10 Apr 2014 06:32 PM
keep searching man, or you probably broke it yourself man
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:35 PM
I never changed the script. It's exactly as it was when I put it in the game.
Report Abuse
CTServant001 is not online. CTServant001
Joined: 01 Feb 2013
Total Posts: 211
10 Apr 2014 06:37 PM
The lines:
while true do
if newPlayer.Character ~= nil then break end
wait(5)
end

This may cause the script to leave the function if the character is not found, and you have no other trigger.

Can't really help you much because the way you presented the problem. No output given or any indications where it went wrong.
Report Abuse
Coogylox is not online. Coogylox
Joined: 05 Jan 2010
Total Posts: 38
10 Apr 2014 06:41 PM
Alright. What other triggers are there? And that's the entirety of the script that I have. I don't know what you mean by output given, and I don't know where it went wrong.
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