Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
|
| 08 Jan 2017 06:31 PM |
So I have a script that should give money to the desired player when a button is clicked, but it says that Line 4's Argument is missing or nil. Any sollutions?
function onClicked() local amt = script.Parent.Parent.Parent.Amt.Cash.Text local name = script.Parent.Parent.Parent.Amt.Name.Text local plr = game.Players:FindFirstChild(name) local cash = plr.ActualMoney.Value cash = cash + amt end script.Parent.MouseButton1Down:connect(onClicked) |
|
|
| Report Abuse |
|
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
| |
|
spot9110
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 475 |
|
|
| 08 Jan 2017 06:40 PM |
debug and try this to see if name is even a player print(name) |
|
|
| Report Abuse |
|
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
| |
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
| |
|
spot9110
|
  |
| Joined: 05 Dec 2009 |
| Total Posts: 475 |
|
|
| 08 Jan 2017 06:46 PM |
then your problem is within these two lines of code local amt = script.Parent.Parent.Parent.Amt.Cash.Text local name = script.Parent.Parent.Parent.Amt.Name.Text
name may actually not be where you have it set at above. Make sure you got the path right. |
|
|
| Report Abuse |
|
|
icelys
|
  |
| Joined: 13 Mar 2016 |
| Total Posts: 49 |
|
|
| 08 Jan 2017 06:47 PM |
Not sure...
try game.Players:WaitForChild(name)? |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2017 06:48 PM |
| script.Parent.MouseButton1Down:connect(function(Player) local amt = script.Parent.Parent.Parent.Amt.Cash.Text local cash = Player.ActualMoney.Value cash = cash + amt end) This is assuming ############# ## a click detector. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2017 06:48 PM |
| assuming script dot parent is a click detector. |
|
|
| Report Abuse |
|
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
|
| 08 Jan 2017 06:49 PM |
| Still says nil. And the name is in the same spot cash is, just a different name. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2017 06:49 PM |
script.Parent.MouseButton1Down:connect(function(Player) local amt = script.Parent.Parent.Parent.Amt.Cash.Text local cash = Player.ActualMoney.Value cash = cash + amt end) |
|
|
| Report Abuse |
|
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
|
| 08 Jan 2017 06:51 PM |
| It's a Gui and it is not meant to go to the player who clicked it, it's pretty much a donate script. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2017 06:51 PM |
function onClicked() local amt = script.Parent.Parent.Parent.Amt.Cash.Text local name = script.Parent.Parent.Parent.Amt.Name.Text local plr = game.Players:FindFirstChild(name) if plr ~= nil then local cash = plr.ActualMoney.Value cash = cash + amt else print('error') end
script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
| |
|
|
| 08 Jan 2017 06:57 PM |
| Well if its a gui and I am assuming, a localscript. Then the player is just game.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
Trestin4
|
  |
| Joined: 11 Oct 2012 |
| Total Posts: 285 |
|
|
| 08 Jan 2017 07:03 PM |
| It's not a local script, and as I said before, it is not for the local player. It's meant to give to other players. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2017 02:48 AM |
| ^ I am really not understand what context this is whatsoever. |
|
|
| Report Abuse |
|
|