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
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 26 Apr 2016 05:27 PM |
c.Value = c.Value + 1 I... Think. |
|
|
| Report Abuse |
|
|
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 |
|
|
| |
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 15 Jun 2013 |
| Total Posts: 9746 |
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|