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 » Game Design
Home Search
 

Re: Nil value?

Previous Thread :: Next Thread 
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 08:22 PM
function leftClick(mouse)
script.Parent.Parent.AnswerBox.Text = script.Parent.Parent.UserName.Value
wait(.1)
local n = script.Parent.Parent.UserName.Value
local h = game.Players:FindFirstChild(n)
wait(.01)
local c = h:WaitForChild("leaderstats"):WaitForChild("Cash")
c.Value = c.Value +1
script.Parent.Parent.UserName.Value = nil
end
script.Parent.MouseButton1Click:connect(leftClick)
-----------------------------------------------------------
Line 7: It says that the h value is nil, but i already identified it, how to fix?


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 09:30 PM
b


Report Abuse
Du_k is not online. Du_k
Joined: 18 Aug 2015
Total Posts: 26
26 Apr 2016 09:38 PM
Wrong section, post this in Scripting

I'm guessing the UserName is a stringvalue,

You're setting it to nil here;
script.Parent.Parent.UserName.Value = nil
Change it to;
script.Parent.Parent.UserName.Value = "" -- Basically resets the text without errors


R15E | Du_k | Approxed | Traide | LegitFreedom
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
26 Apr 2016 09:45 PM
This should be a localscript. Just get the player this way:

local player = game.Players.LocalPlayer


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 09:48 PM
@rec, but it isn't getting the local player, it is looking for the player that has the same name as what is typed in the box, and rewarding 1 cash


Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
26 Apr 2016 09:54 PM
oh. well here

script.Parent.MouseButton1Click:connect(function()
if game.Players:FindFirstChild(script.Parent.Parent.AnswerBox.Text) then
local player = game.Players:FindFirstChild(script.Parent.Parent.AnswerBox.Text)
local Cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
Cash.Value = Cash.Value + 1
end
end)


Report Abuse
iHypered is not online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
27 Apr 2016 02:16 PM
thanks. it works


Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
27 Apr 2016 02:34 PM
np


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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