|
| 23 May 2015 09:08 AM |
Ok so I have this leaderboard: game.Players.PlayerAdded:connect(function(player) --We create a function that will execute when PlayerAdded fires. local leaderstats = Instance.new("Model", player) --We insert an Model into the the new player (player) leaderstats.Name = "leaderstats" end) --closes function
game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) --We create a new IntValue as a child of 'leaderstats' money.Name = "Aquabux" --this is the name you want the leader-stat to be when it shows up in-game. money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later) end)
game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = "Aquabux" money.Value = 0 end) while wait(10) do for _,Player in pairs(game.Players:GetPlayers()) do if Player:FindFirstChild("leaderstats") then Player.leaderstats.Aquabux.Value = Player.leaderstats.Aquabux.Value +10 end end end
And this buy script inserted in a GUI Image Button: player = script.Parent.Parent.Parent.Parent.Parent money = player.leaderstats.Aquabux price = 20 tool = game.Lighting:findFirstChild("Doritos Nacho Cheese")
function buy() if money.Value >= price then money.Value = money.Value - price local a = tool:clone() a.Parent = player.Backpack local b = tool:clone() b.Parent = player.StarterGear
end end script.Parent.MouseButton1Down:connect(buy)
It wont let me buy the item (I have the item in lightning) but I can the amount needed to buy it on test. I checked the output and it said "leaderstats is not a valid member of PlayerGui". Anyone help how to solve it? |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 09:10 AM |
| You put leaderstats in the player not the PlayerGui. |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 09:14 AM |
| When I test it, the model does go into the player, not the GUI. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 23 May 2015 09:51 AM |
| Don't bump your post it just becomes annoying and less people will want to help you as the conversation becomes hard to follow. Only bump if you have a good reason to do so. Anyways I had the same bug but I never tried using a buy function inside a leaderboard before. Also storing things in Lighting is depreciated. Try using ServerStorage. Can you post the script output? |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 09:58 AM |
Sorry, Just really need help.
This is the output: 10:57:26.206 - Use the new http api: yes 10:57:30.741 - DataModel Loading http://www.roblox.com/asset/?id=250656447 10:57:30.830 - Mode 2 failed: "Unable to create D3D device: 887a0004" 10:57:30.831 - Trying mode 3... 10:57:54.076 - Auto-Saving... 10:57:54.802 - Plugin attempting to show toolbar that does not exist - 76 10:57:55.222 - leaderstats is not a valid member of PlayerGui 10:57:55.223 - Script 'Players.Player.PlayerGui.ScreenGui.Frame.ShopScreen.Buy Ico', Line 2 10:57:55.224 - Stack End 10:57:55.226 - leaderstats is not a valid member of PlayerGui 10:57:55.226 - Script 'Players.Player.PlayerGui.ScreenGui.Frame.ShopScreen.Buy Ico', Line 2 10:57:55.227 - Stack End 10:57:55.229 - leaderstats is not a valid member of PlayerGui 10:57:55.229 - Script 'Players.Player.PlayerGui.ScreenGui.Frame.ShopScreen.Buy Ico', Line 2 10:57:55.230 - Stack End 10:57:55.232 - leaderstats is not a valid member of PlayerGui 10:57:55.232 - Script 'Players.Player.PlayerGui.ScreenGui.Frame.ShopScreen.Buy Ico', Line 2 10:57:55.233 - Stack End 10:57:55.234 - leaderstats is not a valid member of PlayerGui 10:57:55.235 - Script 'Players.Player.PlayerGui.ScreenGui.Frame.ShopScreen.Buy Ico', Line 2 10:57:55.236 - Stack End |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Aug 2015 04:50 PM |
| Having this same problem. Anyone know? |
|
|
| Report Abuse |
|
|