|
| 26 Sep 2017 02:37 PM |
My game has a leaderboard. If an item is added to a player's inventory, then the player's leaderstat value should go up. I have no idea how to do this, but I took a crack at it with this: local playerLeaderstats = {} game.Players.PlayerAdded:connect(function(player) playerLeaderstats[player] = {} playerLeaderstats[player]["BricksTouched"] = 0 local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local BricksTouched = Instance.new("IntValue") BricksTouched.Name = "Bricks Touched" BricksTouched.Value = playerLeaderstats[player]["Bricks Touched"] BricksTouched.Parent = leaderstats if tool.Parent == player.Backpack then playerLeaderstats.BricksTouched.Value +1 end end) the leaderboard shows up fine without if tool.Parent == player.Backpack then playerLeaderstats.BricksTouched.Value +1 the code I made in an attempt to accomplish what I previously said, but when it is in the script, the leaderboard disappeared COMPLETELY. Why?
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
soutenu
|
  |
| Joined: 09 Dec 2011 |
| Total Posts: 1021 |
|
|
| 26 Sep 2017 03:13 PM |
| playerLeaderstats[player.Name] would be the proper way to use a dictionary |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 05:54 PM |
Ok. I put playerLeaderstats[player.Name] in place of playerLeaderstats and it didn't do anything. Also, the plus sign in +1 is underlined in red for some reason. helppppp |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 06:24 PM |
| bump.....is the forum ded today? |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 06:28 PM |
no its just that nobody wants to read through a mountain of unorganized code
without tabbing, pasting lua code is utter trash
tagging lua also makes it worse
like why do they need to get rid of our formatting, just tag out the word
#code error("you're*") |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 07:28 PM |
| @gohan31865 if you're not going to help on a HELP REQUEST THREAD whats the point of replying |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 07:46 PM |
"playerLeaderstats.BricksTouched.Value +1"
um this should be pretty self explanatory why its not working..
roblox.Forum["Let's Make A Deal"]:ClearAllChildren() |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 08:03 PM |
@EagleFireClaw Not for me lol |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 08:44 PM |
very confusing
game.Players.PlayerAdded:connect(function(player) playerLeaderstats[player] = {} playerLeaderstats[player]["BricksTouched"] = 0 local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local BricksTouched = Instance.new("IntValue") BricksTouched.Name = "Bricks Touched" BricksTouched.Value = playerLeaderstats[player]["Bricks Touched"] BricksTouched.Parent = leaderstats if tool.Parent == player.Backpack then playerLeaderstats.BricksTouched.Value +1 <-- Red and error it should've been playerleaderstats.BricksTouched.Value = playerleaderstats.BricksTouched.Value + 1 but end end)
print("Scripts Ya Say, I learn em. ;D") |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 09:42 PM |
game.Players.PlayerAdded:connect(function(player) playerLeaderstats[player.Name] = {} playerLeaderstats[player.Name].["BricksTouched"] = 0 local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local BricksTouched = Instance.new("IntValue") BricksTouched.Name = "Bricks Touched" BricksTouched.Value = playerLeaderstats[player]["Bricks Touched"] BricksTouched.Parent = leaderstats if tool.Parent = player.Backpack then playerLeaderstats.BricksTouched.Value = +1 end end)
try that? |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2017 09:50 PM |
Line 12's the problem. >-> `playerLeaderstats.BricksTouched.Value +1` |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2017 08:14 PM |
| playerLeaderstats.BricksTouched.Value = playerLeaderstats.BricksTouched.Value +1 |
|
|
| Report Abuse |
|
|