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: Help

Previous Thread :: Next Thread 
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
01 Sep 2017 09:28 PM
I'm new to using module scripts and tables but ive been trying to make a simple buy button and i keep getting the error message attempt to index field '?' (a nil value). Does anybody know why.

My script:
local playerLeaderstats = {}


playerLeaderstats.add = function(player)
playerLeaderstats[player] = {}
playerLeaderstats[player]["Money"] = 0
# #l################################## 0 - kills value idk y its blocked
local stats = Instance.new('Folder',player)
stats.Name = 'leaderstats'
local kills = Instance.new('IntValue',stats)
kills.Name = 'Kills'
kills.Value = playerLeaderstats[player]["Kills"]
local money = Instance.new('IntValue',stats)
money.Name = 'Credits'
playerLeaderstats[player]["Money"] = 100
money.Value = playerLeaderstats[player]["Money"]
end



playerLeaderstats.Buy = function(price,Item,player)
local money = player.leaderstats.Credits
local slots = player.CInventory:FindFirstChild("CaseSlots")
print("got em "..price)
player.PlayerGui.Buy.Enabled = false
workspace.CurrentCamera.Blur:Remove()
player.PlayerGui.Logos.Enabled = true
player.PlayerGui["Cash/Case"].Enabled = true

if playerLeaderstats[player]["Money"] >= price then -- This is where im getting the error message
print("Rich kid")
playerLeaderstats[player]["Money"] = playerLeaderstats[player]["Money"] - price
print (playerLeaderstats[player]["Money"])
money.Value = playerLeaderstats[player]["Money"]
for i = 1,10 do
local Slot = slots:WaitForChild("Slot"..i)
if Slot.Equip.Value ~= Item then
if Slot.Equip.Value == "" then
Slot.Equip.Value = Item
Slot.Amount.Value = 1
break
else
print("Already Equipped")
end
else
Slot.Amount.Value = Slot.Amount.Value + 1
break
end
end
player.PlayerGui.Cant.Can:TweenPosition(UDim2.new(1,0,0.85,0),"In","Quint",0.5,true)
wait(2)

player.PlayerGui.Cant.Can:TweenPosition(UDim2.new(1.5,0,0.85,0),"In","Quint",0.5,true)
else
money.Value = playerLeaderstats[player]["Money"]
player.PlayerGui.Cant.Buy:TweenPosition(UDim2.new(1,0,0.85,0),"In","Quint",0.5,true)
wait(2)

player.PlayerGui.Cant.Buy:TweenPosition(UDim2.new(1.5,0,0.85,0),"In","Quint",0.5,true)

end
end

return playerLeaderstats
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
01 Sep 2017 09:40 PM
bump
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
01 Sep 2017 09:51 PM
which line throws the error?
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
01 Sep 2017 09:57 PM
the line i marked with -- This is where im getting the error message
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
01 Sep 2017 09:59 PM
You're trying to index a nil value. That's what the error says.


Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
01 Sep 2017 10:00 PM
how do i fix it then # it works when i dont create a test server
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
01 Sep 2017 10:14 PM
bump
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
01 Sep 2017 10:32 PM
bump
Report Abuse
InfiniteYield is not online. InfiniteYield
Joined: 01 Mar 2012
Total Posts: 762
01 Sep 2017 10:39 PM
well we'd help but the marked line is censored..


Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 06:19 AM
is it? well its the line if playerLeaderstats[player]["Money"] >= price then
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 07:23 AM
bump
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 07:42 AM
bump
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 08:34 AM
bump help plz
Report Abuse
systematicaddict is not online. systematicaddict
Joined: 13 Jul 2012
Total Posts: 4188
02 Sep 2017 08:50 AM
You never defined price?
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 08:53 AM
i did in the functions brackets - playerLeaderstats.Buy = function(price.item,player)
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 09:46 AM
bump
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 10:29 AM
bump
Report Abuse
Avallex is not online. Avallex
Joined: 13 Mar 2013
Total Posts: 31
02 Sep 2017 10:33 AM
You're not giving us a lot to work with..
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 10:46 AM
what do you need
Report Abuse
chexyalani is online. chexyalani
Joined: 26 Mar 2017
Total Posts: 694
02 Sep 2017 10:51 AM
probably because of 'playerLeaderstats[player]["Money"]'.

It might be saying 'player' is nil.
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 11:17 AM
how do i fix this then
Report Abuse
chexyalani is online. chexyalani
Joined: 26 Mar 2017
Total Posts: 694
02 Sep 2017 11:18 AM
Are you including the player argument when you're calling the Buy function?
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 11:50 AM
yea i am - ################################ Case",game.Players.LocalPlayer)
Report Abuse
billyandme is not online. billyandme
Joined: 05 Apr 2009
Total Posts: 84
02 Sep 2017 11:59 AM
the tags are just calling the function
Report Abuse
chexyalani is online. chexyalani
Joined: 26 Mar 2017
Total Posts: 694
02 Sep 2017 12:03 PM
The module is required and the function is fired from a localscript right?
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