Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Please help my script keeps breaking and not working? (Read desc)

Asked by
Da_ve5 0
6 years ago
01print("Cash Leaderboard Loaded")
02 
03 
04function onPlayerEntered(newPlayer)
05 
06    local stats = Instance.new("IntValue")
07    stats.Name = "leaderstats"
08 
09    local cash = Instance.new("IntValue")
10    cash.Name = "Money"       --name of currency (e.g. cash, money, resources, bucks, etc.)
11    cash.Value = 1000      --starting money.
12 
13    cash.Parent = stats
14    stats.Parent = newPlayer
15end
View all 33 lines...

It won't give me money nor I can't see it on the leaderboard. Please help.

2 answers

Log in to vote
0
Answered by 6 years ago

Hey,

You've got two unnecessary "end"s on line 20 and 21.

You usually have an end after an if, an function and so on.

I also changed ChildAdded to PlayerAdded, that is better and then it wont break if something else is inserted into Players.

Here is the code with the problem solved:

01print("Cash Leaderboard Loaded")
02 
03 
04function onPlayerEntered(newPlayer)
05 
06    local stats = Instance.new("IntValue")
07    stats.Name = "leaderstats"
08 
09    local cash = Instance.new("IntValue")
10    cash.Name = "Money"       --name of currency (e.g. cash, money, resources, bucks, etc.)
11    cash.Value = 1000      --starting money.
12 
13    cash.Parent = stats
14    stats.Parent = newPlayer
15end
View all 31 lines...
0
thanks Da_ve5 0 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

The first problem is that when you are making a leaderboard you first have to make a model and name it 'leaderstats'.

This will work, I removed the first function because I didn't see the purpose of it

01print("Cash Leaderboard Loaded")
02 
03game.Players.PlayerAdded:connect(function(p)
04local stats = Instance.new("Model")
05stats.Parent = p
06stats.Name = "leaderstats"
07local money = Instance.new("IntValue")
08money.Parent = stats
09money.Name = "Cash"
10money.Value = 100
11while true do
12wait(5)
13money.Value = money.Value + 10
14end
15end)
0
it doesn't have to be a model, it can be anything with the name "leaderstats" theking48989987 2147 — 6y

Answer this question