NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 12:37 PM |
Hey guys,
The code below isn't working, it keeps saying "Colour is not a valid member of Folder". I get that it isn't a member, but the argument should've made it one. Is there a way to get this to work?
Code: function voter(partColour) Colour = partColour if Voted == false then print("player bool works") game.ReplicatedStorage.Votes.Colour.Value = game.ReplicatedStorage.Votes.Colour.Value + 1 print("Value upped") Voted = true wait(10) Voted = false end end
script.Parent.GreenPartVote.MouseButton1Click:connect(voter(GreenPart)) |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
| |
|
|
| 01 Mar 2016 02:43 PM |
| That means, that the Colour NumberValue you are trying to edit, is not in that folder. |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 01 Mar 2016 02:46 PM |
Try the following:
game.ReplicatedStorage.Votes[Colour].Value ... |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 03:59 PM |
I tried, but it gives this error: Players.Player1.PlayerGui.VoteGui.Voting.VoteScript:6: bad argument #2 to '?' (string expected, got nil)
This is the code: Voted = false
function voter(partColour) if Voted == false then print("player bool works") game.ReplicatedStorage.Votes[partColour].Value = game.ReplicatedStorage.Votes[partColour].Value + 1 print("Value upped") Voted = true wait(10) Voted = false end end
buttonThere = game.ReplicatedStorage.VoteGui.Voting:WaitForChild("GreenPart")
if buttonThere then script.Parent.GreenPart.MouseButton1Click:connect(voter(GreenPart)) |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 01 Mar 2016 04:04 PM |
Try this (definitely not ideal...):
script.Parent.GreenPartVote.MouseButton1Click:connect(function() voter(GreenPart) end)
|
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 04:06 PM |
| Nope, getting the same error! Am I trying to do something that's not possible to begin with? |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 01 Mar 2016 04:09 PM |
What is 'GreenPart'? Is it defined earlier within the script?
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 04:12 PM |
| What is the point of this script? It might help to better understand the problem |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 04:13 PM |
| GreenPart isn't definded earlier, only as argument inside the click event. It's actually a part that's green. If it gets the most votes it spawns, if another part gets the most vote, that part will spawn. |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 04:15 PM |
| The point of this part of the script is to reduce the necessart lines of code. If I call this function inside all of the clicked events, I only have to change the argument to increase the ammount of votes :) |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 01 Mar 2016 04:15 PM |
| You're passing it a nil value. If you wish to find a child of game.ReplicatedStorage.Votes by the name of "GreenPart", pass it as a string [i.e. voter("GreenPart") .] |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 04:17 PM |
| Owww yesss, it works! Thanks a lot :) |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 04:21 PM |
| Welp it works, but now it's upping the value without me even clicking it o.0 |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
|
| 01 Mar 2016 04:42 PM |
| *bump* Not solved after all I'm afraid :( |
|
|
| Report Abuse |
|
|
NCW90
|
  |
| Joined: 14 Nov 2011 |
| Total Posts: 65 |
|
| |
|