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: Custom leaderstats script not working;

Previous Thread :: Next Thread 
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 02:01 PM
Focus mainly on the leaving section, the players karts dont dissapear when they leave, im not too sure if this is with the :WaitForDataReady() in PlayerAdded. Help?


Game.Players.PlayerAdded:connect(function( Player )
Instance.new("BoolValue", Player).Name = "Roullete"
Instance.new("BoolValue", Player).Name = "Racing"
Instance.new("BrickColorValue", Player).Name = "Colour"
Instance.new("NumberValue", Player).Name = "Kart"
l = Instance.new("NumberValue", Player)
l.Name = "Lap"
Instance.new("NumberValue", Player).Name = "Section"
Instance.new("NumberValue", Player).Name = "Position"
Instance.new("IntValue", Player).Name = "leaderstats"
Instance.new("IntValue", Player.leaderstats).Name = "VR"
Instance.new("IntValue", Player.leaderstats).Name = "Coins"
pwnage = 1000
if game.PlaceId ~= 0 then
Player:WaitForDataReady()
pwnage = Player:LoadNumber("Ranking")
end
if pwnage ~= 0 then
Player.leaderstats.VR.Value = pwnage
else
Player.leaderstats.VR.Value = 1000
end
Player.CharacterAdded:connect(function( Character )
Character.Humanoid.Died:connect(function()
if Player.Racing.Value == true then
if game.Workspace:findFirstChild("Karts") then
if game.Workspace.Karts:findFirstChild(Player.Name) then
game.Workspace.Karts[Player.Name]:Destroy()
game.Workspace.Positions[Player.Name].Value = 100000
game.Workspace.Positions[Player.Name].Name = "NotUsed"
end
end
Player.Racing.Value = false
Player.leaderstats.VR.Value = Player.leaderstats.VR.Value - 2
if script.Parent.CurrentRacers.Value ~= 0 then
script.Parent.CurrentRacers.Value = script.Parent.CurrentRacers.Value - 1
end
end
end)
end)
end)

game.Players.PlayerRemoving:connect(function(p)
print(p.Name.." Is Leaving")
if p.Racing.Value == true then
print(p.Name.." Was Racing")
if game.Workspace.Karts:findFirstChild(p.Name) then
print(p.Name.." Had His Kart Removed")
game.Workspace.Karts[p.Name]:Destroy()
game.Workspace.Positions[p.Name].Value = 100000
game.Workspace.Positions[p.Name].Name = "NotUsed"
end
if script.Parent.CurrentRacers.Value ~= 0 then
script.Parent.CurrentRacers.Value = script.Parent.CurrentRacers.Value - 1
end
elseif game.Workspace.Practice:findFirstChild(p.Name) then
game.Workspace.Practice[p.Name]:Destroy()
end
if p.DataReady == true then
p:SaveNumber("Ranking", p.leaderstats.VR.Value)
end
end)
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
03 Apr 2012 02:21 PM
You can't save data once the player has left.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 02:28 PM
Prehistoric, the thing is, it DOES do that. maybe it saves then breaks after?
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 02:38 PM
bump
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 06:12 PM
bumpo
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 06:55 PM
Bump! Help please!
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
03 Apr 2012 06:57 PM
@Prehistoric

I read somewhere that you only need a reference of the player,
though I can't verify this.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 07:06 PM
Okay, after witnessing gameplay, heres what i can piece up:

Players joining still get all the stuff and data loaded:
PlayerAdded = A.Ok.

Players Leaving On the other hand, DO have their data saved, but have some wierd problems with the karts staying even though its all valid compared to the 'if' statements.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
03 Apr 2012 07:23 PM
Bump, im in need of some serious help here. I understand many dont know the answer but i'd appreciate it if people who did know the answer would post.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 09:22 AM
bump.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 11:06 AM
Would it be better if i put the data persistance code in another script?
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 11:16 AM
Bump!
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 11:26 AM
Cmon i need help!
Report Abuse
radiogamer is not online. radiogamer
Joined: 06 Oct 2008
Total Posts: 1975
04 Apr 2012 11:39 AM
'if game.Workspace.Karts:findFirstChild(p.Name) then'

Does this mean the kart has the name of the player?

If so, can't you place something like:

while true do
if game.Players:findFirstChild(script.Parent.Name) == nil then
script.Parent:remove()
end
wait()
end


Put this in the karts
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 11:59 AM
That would work, but at mass it would be inefficient, plus it wouldnt solve the other problems like races not finishing when there are no racers left.
Report Abuse
radiogamer is not online. radiogamer
Joined: 06 Oct 2008
Total Posts: 1975
04 Apr 2012 12:02 PM
What exactly of the playerleave doesn't work?
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 12:03 PM
That i cant explain as i cant retreive output from roblox servers.
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 12:06 PM
Radio, im re-posting a previous post of what i know.

Players joining still get all the stuff and data loaded:
PlayerAdded = A.Ok.

Players Leaving On the other hand, DO have their data saved, but have some wierd problems with the karts staying even though its all valid compared to the 'if' statements.
Report Abuse
radiogamer is not online. radiogamer
Joined: 06 Oct 2008
Total Posts: 1975
04 Apr 2012 12:08 PM
what if you ran it in a local server (studio) without the save data thingie.

What output do you get there?
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
04 Apr 2012 12:12 PM
With a local server it cant use more than 1 player because
A: Confusion with kart and player names
B: Only got 2gb memory

i honestly think the problem is related to the data saving.
Report Abuse
radiogamer is not online. radiogamer
Joined: 06 Oct 2008
Total Posts: 1975
04 Apr 2012 12:26 PM
Tested it without the save thingie.

It works, so it's indeed something about save data.

A friend of mine has a working leaving save thingie, I will look what's written in there...
Report Abuse
radiogamer is not online. radiogamer
Joined: 06 Oct 2008
Total Posts: 1975
04 Apr 2012 12:55 PM
Hmm, it's just a normal SaveNumber method...

Guess these are those moments where you have to blame the Roblox program...
Report Abuse
crazyblox is not online. crazyblox
Joined: 16 Mar 2008
Total Posts: 6139
05 Apr 2012 09:13 AM
So i guess ill just put the load and save in a script of its own so it wont interfere?
Report Abuse
MrMcMahon532 is not online. MrMcMahon532
Joined: 07 Apr 2011
Total Posts: 2
05 Apr 2012 09:27 AM
I think so.
Report Abuse
breuning is not online. breuning
Joined: 30 Oct 2008
Total Posts: 4268
05 Apr 2012 10:21 AM
Blame John... and the ImPlicitNgine.
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