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: help me with my funky leaderboard

Previous Thread :: Next Thread 
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
13 Apr 2014 08:57 PM
I'm trying to make it so that i have this leaderboard where every 4 seconds you get a gem and every 3 seconds you get a jewel. It only works with the gems ingame, the jewels do not get added every 3 seconds

can you help me with this?

--______________________________________
print("Community Leaderboard script loaded")
function Entered(player)
wait()

if player:findFirstChild("leaderstats") ~= nil then
player.leaderstats:remove()
end

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

local money = Instance.new("IntValue")
money.Parent = stats
money.Name = "Gems"--change Cash to whatever you like...
money.Value = 0

local points = Instance.new("IntValue")
points.Name = "Jewels"
points.Value = 0
points.Parent = stats


while true do
wait(4)
money.Value = money.Value + 1
end
while true do
wait(3)
points.Value = points.Value + 1
end
end



game.Players.PlayerAdded:connect(Entered)

c = game.Players:GetChildren()
for i=1, #c do
Entered(c[i])
end
--____________________________________________________

sparklelion
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
13 Apr 2014 09:06 PM
if there is no way to solve ill have to make it so that you buy jewels manually with robux or tix

sparklelion
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
14 Apr 2014 07:30 PM
bump

sparklelion
Report Abuse
bombastically is not online. bombastically
Joined: 28 Feb 2014
Total Posts: 128
14 Apr 2014 07:58 PM
Spawn(function()
while true do
wait(4)
money.Value = money.Value + 1
end end)
Spawn(function()
while true do
wait(3)
points.Value = points.Value + 1
end
end end)

Spawn creates a new thread so it allows both of those while true do statements to run at once.
The jewel loop wasn't being run because the compiler was reading that gem loop and it never ended so it never went down to get to the jewel loop.

Example:

while wait() do end
print("hello")
-- This will not print hello because its doing the loop and never gets past it to print "hello"
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
14 Apr 2014 10:34 PM
doesnt seem to work, I put it in the place of

while true do
wait(4)
money.Value = money.Value + 1
end
while true do
wait(3)
points.Value = points.Value + 1
end
end



the game just shows up with no leaderboard

sparklelion
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
14 Apr 2014 10:38 PM
im gonna try to edit it still though based on what you said

sparklelion
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
15 Apr 2014 01:03 PM
fixed it!
what you said still didnt work tho.

sparklelion
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
15 Apr 2014 02:32 PM
well not exactly fixed...
i was able to make them both count up and whatever
but instead of doing their own things, gems going up every 4 seconds, jewels going up every 3, they wait for eachother.

like a gem would go up after 4 seconds pass, 3 seconds later a jewel goes up, and then 4 seconds later a gem goes up.

i've tried tweaking the script about 10 times already, the roblox wiki doesn't show much for this.

sparklelion
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
15 Apr 2014 02:35 PM
function Source()
while true do
wait(4)
money.Value = money.Value + 1
end
end
end

local newCoroutine = coroutine.create(Source)
coroutine.resume(newCoroutine)

while true do
wait(4)
points.Value = points.Value + 1
end
end
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
15 Apr 2014 02:38 PM
Use Coroutine next time, its easier to remember

This is shorter one

updateMoney = coroutine.warp

while wait(4) do
money.Value = money.Value + 1
end

updateMoney()

while wait(4) do
points.Value = points.Value + 1
end
end
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
15 Apr 2014 02:41 PM
this one works, thanks!

if it doesn't seem to work you just have to move the ends around a bit.

sparklelion
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
15 Apr 2014 02:43 PM
Idk does it work, I just wrote this without checking... :P
Report Abuse
Zeriten is not online. Zeriten
Joined: 05 Nov 2012
Total Posts: 19839
15 Apr 2014 02:45 PM
it does work, the shorter one doesn't work though.

it's still awesome though :p

sparklelion
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
15 Apr 2014 02:46 PM
Idk Ill check it..
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
15 Apr 2014 02:54 PM
Oh here you go

updateMoney = coroutine.wrap(function()
while wait(1) do
print("Money")
end
end)

updatePoints = coroutine.wrap(function()
while wait(0.5) do
print("Points")
end
end)

updateMoney()
updatePoints()


To run coroutine.wrap, you need put a name of function you want and do

function = crorutine.wrap(function()
--Your loop here
end)

then call function

function()
Report Abuse
Ace23333 is not online. Ace23333
Joined: 20 Nov 2011
Total Posts: 1341
15 Apr 2014 02:55 PM
coroutine.wrap*
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