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: Leaderboards Question

Previous Thread :: Next Thread 
synzoxre13 is not online. synzoxre13
Joined: 26 Sep 2016
Total Posts: 45
28 Oct 2016 03:06 AM
In the Roblox Wiki leaderboard tutorial

tutorial page -> http://wiki.roblox.com/index.php?title=Leaderboard
_____________________________________________________________________________________________
_____________________________________________________________________________________________

game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = 0
money.Parent = leaderstats
end)
while wait(5) do
for _, player in ipairs(game.Players:GetPlayers()) do
if player:FindFirstChild("leaderstats") then
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1
end
end
end

--{Here is the more standardized leaderboard example. It inserts the leaderstat model into the player, inserts the intvalue money into the leaderstats, and below it has the in pairs loop to add to every player a value of 1 to the money intvalue for every wait(5)}--
_____________________________________________________________________________________________
_____________________________________________________________________________________________


--A table for holding all the player's leaderstat values
local playerLeaderstats = {}

game.Players.PlayerAdded:connect(function(player)
playerLeaderstats[player] = {}
playerLeaderstats[player]["Money"] = 0
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = playerLeaderstats[player]["Money"]
money.Parent = leaderstats
end)

while wait(5) do
for _, player in pairs(game.Players:GetPlayers()) do
--We don't use the IntValue's value because an exploiter can modify it.
playerLeaderstats[player]["Money"] = playerLeaderstats[player]["Money"] + 1
if player:FindFirstChild("leaderstats") then
player.leaderstats.Money.Value = playerLeaderstats[player]["Money"]
end
end
end

--{Here's the same script, except it's built a table along with the leaderboard and increments the intvalue from the table instead of a direct value as kind of an extra check step to circumvent manipulation of the direct value, although it says that you can Workspace.FilteringEnabled set to true.}--
_____________________________________________________________________________________________
_____________________________________________________________________________________________


So the only thing I'm having trouble with is the leaderboard built to a table.

Please give me a working example of how I can make a brick that when touched, adds +1 to the "Money" IntValue using the leaderboard.

I tried quite a few different variations of what I thought should work but didnt. Sorry for such a basic question, but I'm doing my best :p


Report Abuse
synzoxre13 is not online. synzoxre13
Joined: 26 Sep 2016
Total Posts: 45
28 Oct 2016 03:11 AM
"Please give me a working example of how I can make a brick that when touched, adds +1 to the "Money" IntValue using the leaderboard THAT USES THE TABLE****"
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
28 Oct 2016 03:22 AM
remote events
Report Abuse
synzoxre13 is not online. synzoxre13
Joined: 26 Sep 2016
Total Posts: 45
28 Oct 2016 05:22 AM
ServerScriptService - > Script
________________________________________________________________________________________
game.Players.PlayerAdded:connect(function(player)
local event = Instance.new("RemoteEvent")
event.Parent = player
event.Name = "MyClientEvent"
wait(1)
pointPart = game.Workspace.PointPart
local function fireClient()
event:FireClient(player)
end

pointPart.Touched:connect(fireClient)



end)
_______________________________________________________________________________________
_______________________________________________________________________________________
StarterPlayer -> StarterPlayerScripts -> LocalScript
_______________________________________________________________________________________
local player = game.Players.Player1
game.Players.LocalPlayer:WaitForChild("MyClientEvent").OnClientEvent:connect(function()
player.leaderstats.Points.Value = playerLeaderstats.Points.Value + 1
end)
______________________________________________________________________________________
______________________________________________________________________________________

Okay, so somehow I've managed to get a client event to activate a serverscript. In this case, it will add 1 point to the points intvalue of the leaderstats leaderboard. But in the localscript, I've had to specify local player = game.Players.Player1

In that instance, what would be an easy way to obtain the directory "Player1" regardless of whether they are player1,player2,player3,etc without manually putting that in?

Also, regarding the first post, how would I define "playerLeaderstats" like...

playerLeaderstats[player]["Points"] = playerLeaderstats[player]["Points"] + 500000
^^^^^^^^^^^^^^^^^
if I were to try and use this from the table that was created. When referenced outside of the serverscript that this table was created in, it brings up a nil value. How would I recall that table?
Report Abuse
synzoxre13 is not online. synzoxre13
Joined: 26 Sep 2016
Total Posts: 45
28 Oct 2016 05:53 AM
halp? :3
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