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 » Scripters
Home Search
 

Re: Help me squash this script bug.

Previous Thread :: Next Thread 
ace12345678135 is not online. ace12345678135
Joined: 30 Aug 2008
Total Posts: 341
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
Kofphtastrophe is not online. Kofphtastrophe
Joined: 28 Oct 2015
Total Posts: 154
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
ace12345678135 is not online. ace12345678135
Joined: 30 Aug 2008
Total Posts: 341
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
cntkillme721 is not online. cntkillme721
Joined: 17 Sep 2009
Total Posts: 351
06 Sep 2016 10:49 AM
Don't put those wait()'s there. And parent to leaderstats after setting the name
Report Abuse
TimeTicks is not online. 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
ace12345678135 is not online. ace12345678135
Joined: 30 Aug 2008
Total Posts: 341
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
ace12345678135 is not online. ace12345678135
Joined: 30 Aug 2008
Total Posts: 341
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 is not online. 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
ace12345678135 is not online. ace12345678135
Joined: 30 Aug 2008
Total Posts: 341
06 Sep 2016 11:07 AM
wait...
Report Abuse
ace12345678135 is not online. ace12345678135
Joined: 30 Aug 2008
Total Posts: 341
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
Kofphtastrophe is not online. Kofphtastrophe
Joined: 28 Oct 2015
Total Posts: 154
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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