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: Buying/Leaderstats Problem

Previous Thread :: Next Thread 
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
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
bluefrog53 is not online. bluefrog53
Joined: 05 Feb 2012
Total Posts: 766
23 May 2015 09:10 AM
You put leaderstats in the player not the PlayerGui.
Report Abuse
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
23 May 2015 09:14 AM
When I test it, the model does go into the player, not the GUI.
Report Abuse
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
23 May 2015 09:20 AM
Anyone else?
Report Abuse
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
23 May 2015 09:33 AM
Bump.
Report Abuse
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
23 May 2015 09:48 AM
Bump.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
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
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
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
TheOnlyYaY is not online. TheOnlyYaY
Joined: 10 Jun 2014
Total Posts: 194
23 May 2015 11:28 AM
Can anyone else help?
Report Abuse
ZocketTeal is not online. ZocketTeal
Joined: 25 Aug 2013
Total Posts: 135
25 Aug 2015 04:50 PM
Having this same problem. Anyone know?
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