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
 

Re: Function and argument not working

Previous Thread :: Next Thread 
NCW90 is not online. 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 is not online. NCW90
Joined: 14 Nov 2011
Total Posts: 65
01 Mar 2016 02:19 PM
*bump*
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
01 Mar 2016 04:12 PM
What is the point of this script? It might help to better understand the problem
Report Abuse
NCW90 is not online. 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 is not online. 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 is not online. 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 is not online. NCW90
Joined: 14 Nov 2011
Total Posts: 65
01 Mar 2016 04:17 PM
Owww yesss, it works! Thanks a lot :)
Report Abuse
NCW90 is not online. 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 is not online. 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 is not online. NCW90
Joined: 14 Nov 2011
Total Posts: 65
01 Mar 2016 05:17 PM
*bump*
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