|
| 06 Sep 2016 10:12 AM |
for _, player in pairs(game.Players:GetPlayers()) do local Kills = Instance.new("IntValue",player.leaderstats) wait() Kills.Name = "Kills" Kills.Value = 0 wait() local Deaths = Instance.new("IntValue",player.leaderstats) Deaths.Name = "Deaths" Deaths.Value = 0 wait(1)
it follows the kills lines correctly, and adds the int value into leaderstats as its supposed to, then, it adds the deaths value. the values name shows up in leaderstats as deaths if I click on my player, but it just shows up as "Value" on my actual leaderboard. ive been at this for a while. it just doesn't make sense. |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2016 10:26 AM |
To be able to fix this one would need to inspect the whole structure of the "leaderstats"
And something you don't want to hear; that script's gonna fail.
You do realize that only updates once, and you would need that to fire everytime a player enters; if so, every player would have a ton of IntValues in them because that (for _,player) would affect every player when a player leaves. |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2016 10:47 AM |
| it actually fires every time a map is chosen in my game, then destroys itself when the game is over. needless to say I'm making my own leaderboard gui, for when players are in game. |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2016 10:49 AM |
| Don't put those wait()'s there. And parent to leaderstats after setting the name |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 06 Sep 2016 10:51 AM |
Instead of destroying the stats, simply clear the values in them.
for i,v in next, game.Players:GetPlayers() do local stats = v:WaitForChild('Stats') local kills = stats:WaitForChild('Kills') local deaths = stats:WaitForChild('Deaths') kills.Value = 0 deaths.Value = 0 end
Then load the leaderboard.
GenerateLeaderboard = function() for i,v in next, game.Players do local gui = Instance.new('Frame',leaderboard) gui.Size = UDim2.new(1,0,0,leaderboard/MaxPlayers) gui.Position = UDim2.new(0,0,0,i*gui.AbsoluteSize.Y-gui.AbsoluteSize.Y) --others guis inside frame to show player name, kills, and deaths --other stuff to change color of guis etc end end
This will all be called with a remote event to simplify things.
|
|
|
| Report Abuse |
|
|
|
| 06 Sep 2016 11:03 AM |
| n my game, players will be sent to a lobby where they can still kill players. to keep these kills from getting on a leaderboard, I made sure there was no leaderboard to get onto until the game already started. mainly because idk how to keep them from killing each other in the lobby. I have lethal gear allowed when they spawn in. anything from catalog that's a power up or that can kill is allowed. |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2016 11:06 AM |
| also the wait times were part of the bug testing I was doing, and the stats are already parented to leaderstats through the local I established in the longer lines. believe me ive checked. thank you for the advice though. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 06 Sep 2016 11:06 AM |
You could either, use a forcefield, or maximize their health, OR simply remove the tools in the lobby. The last is the best option.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 06 Sep 2016 11:09 AM |
| ill use that script though lol and I may just set their health to math.huge while they are in the lobby |
|
|
| Report Abuse |
|
|
|
| 06 Sep 2016 11:13 AM |
^ TimeTicks
for i,v in next, game.Players:GetPlayers() do local stats = v:WaitForChild('Stats') local kills = stats:WaitForChild('Kills') local deaths = stats:WaitForChild('Deaths') kills.Value = 0 deaths.Value = 0 end
Those "WaitForChild"s are badly located.
If for some reason a player doesn't have one of the stats set to be waited for, the whole script will stop.
Also, the "in next" is useless there.
This is how i would do it:
for z,v in pairs(game.Players:GetChildren()) do if v.ClassName == "Player" then if v:FindFirstChild("leaderstats") then for i,v in pairs(v.leaderstats:GetChildren()) do if v.ClassName == "IntValue" and v.Name == "kills" or v.Name == "deaths" then v.Value = 0 end end end end end |
|
|
| Report Abuse |
|
|