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
 

Why is this underlined red?

Previous Thread :: Next Thread 
iHypered is online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 05:25 PM
function leftClick(mouse)
script.Parent.AnswerBox.Text = script.Parent.Parent.UserName
wait(.1)
local n = script.Parent.Parent.UserName
local h = game.Players:FindFirstChild(n)
local c = h:WaitForChild("leaderstats"):WaitForChild("Cash")
c.Value +1
script.Parent.MouseButton1Click:connect(leftClick)
end

--------------------
+ is underlined red as an error, what can I do to fix it? It says it expected a = when I hover mouse. I also tried ingame, it said samething as it did in script.


Report Abuse
Inigo18 is online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
26 Apr 2016 05:27 PM
c.Value = c.Value + 1
I... Think.
Report Abuse
iHypered is online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 05:29 PM
@in, it got rid of the underline, thanks. going to test ingame now and see results


Report Abuse
killerbot29003 is online. killerbot29003
Joined: 04 Oct 2014
Total Posts: 3054
26 Apr 2016 05:30 PM
c.Value = c.Value + 1


Report Abuse
Inigo18 is online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
26 Apr 2016 05:31 PM
Soooo?
Report Abuse
iHypered is online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 05:33 PM
hmm it did nothing, but no error is popping up on developer console


Report Abuse
Inigo18 is online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
26 Apr 2016 05:36 PM
Add prints in each line to see where the code stops. Maybe its the WaitForChild.
Report Abuse
Inigo18 is online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
26 Apr 2016 05:37 PM
In fact, I'm not really sure if you can put two WaitForChild() in the same line... Still you may wanna try the print thing first as I may be wrong too
Report Abuse
eRanged is online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
26 Apr 2016 05:44 PM
you can
Report Abuse
iHypered is online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 05:46 PM
Just added prints. Nothing at all printed both in studio and in game. I clicked it multiple times too. It got to the part with the red line before in output, idk problem


Report Abuse
SkyDoesMinecraft is online. SkyDoesMinecraft
Joined: 15 Jul 2012
Total Posts: 656
26 Apr 2016 05:48 PM
local deb=false

function leftClick(mouse)
if deb then return end deb=true
script.Parent.AnswerBox.Text = script.Parent.Parent.UserName
wait(.1)
local n = script.Parent.Parent.UserName
local h = game.Players:FindFirstChild(n)
local c = h:WaitForChild("leaderstats"):WaitForChild("Cash")
c.Value=c.Value+1
deb=false
end

script.Parent.MouseButton1Click:connect(leftClick)
Report Abuse
DivinePheonix is not online. DivinePheonix
Joined: 30 Mar 2011
Total Posts: 11190
26 Apr 2016 05:49 PM
Why is the event inside the function, it will never run. . .
function leftClick(mouse)
script.Parent.AnswerBox.Text = script.Parent.Parent.UserName
wait(.1)
local n = script.Parent.Parent.UserName
local h = game.Players:FindFirstChild(n)
local c = h:WaitForChild("leaderstats"):WaitForChild("Cash")
c.Value = c.Value +1
end
script.Parent.MouseButton1Click:connect(leftClick)

Report Abuse
iHypered is online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 06:06 PM
now it says h is a nil value in output, but i already defined it...

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
end
script.Parent.MouseButton1Click:connect(leftClick)




Report Abuse
eRanged is online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
26 Apr 2016 06:15 PM
You should always be using LocalPlayer if its a LocalScript, it's way easier.

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats"):WaitForChild("Cash")

script.Parent.MouseButton1Click:connect(function()
Cash.Value = Cash.Value + 1
end)


Report Abuse
eRanged is online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
26 Apr 2016 06:15 PM
Mistike....

local player = game.Players.LocalPlayer
local Cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")

script.Parent.MouseButton1Click:connect(function()
Cash.Value = Cash.Value + 1
end)


Report Abuse
iHypered is online. iHypered
Joined: 09 Nov 2010
Total Posts: 2751
26 Apr 2016 06:19 PM
@eranged, that wouldnt work for what this is for. it is where you type in the username to give cash, and it uses the answer to go to a string value, then it searches for the name of the value in players and give that player the points.


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