|
| 14 Oct 2015 12:37 AM |
Players.Player.PlayerGui.ScreenGui.Check.Script:4: attempt to call field 'MouseButton1Down' (a userdata value) -- error
codes = {FOLLOWING = true, OTHERCODE = true} player = game.Players.LocalPlayer
script.Parent.MouseButton1Down(function() local gui = script.Parent.Parent local input = codes[gui.Input.Text] if input then if input == "FOLLOWING" then print("FOLLOWING") elseif input == "OTHERCODE" then print("Other code") end end end) Anyone know the problem? The script is a regular script inside a button |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 12:42 AM |
codes = {FOLLOWING = true, OTHERCODE = true} player = game.Players.LocalPlayer
player:GetMouse().Button1Down:connect(function() local gui = script.Parent.Parent local input = codes[gui.Input.Text] if input then if input == "FOLLOWING" then print("FOLLOWING") elseif input == "OTHERCODE" then print("Other code") end end end) |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 12:45 AM |
| It doesn't want to print out anything, any help there? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Oct 2015 12:46 AM |
| script.Parent.MouseButton1Down:connect(your code |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 12:49 AM |
| It still doesn't want to print out anything |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Oct 2015 12:50 AM |
local gui = script.Parent.Parent local codes = {FOLLOWING = true, OTHERCODE = true} local player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:connect(function() local input = codes[gui.Input.Text] if input then print(input) else print("Does not exist") end end)
The way you have it set up, you need to type it in all capital letters, if you want it to be case-insensitive then just string.upper the gui.Input.Text |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 12:54 AM |
| It's printing out true now, but I want it to check if one of the codes is in there, say FOLLOWING, ill have the if function for FOLLOWING, else if the input.Text = OTHERCODE then I want to do separate stuff for that. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 14 Oct 2015 12:56 AM |
One way of doing it that is easy to customize and extend:
local codes = { FOLLOWING = function() print("FOLLOWING typed") end, OTHERCODE = function() print("OTHERCODE typed") end }
And if codes[blah] exists, you just call it (codes[blah]()) and if you need to, pass arguments. |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 12:57 AM |
| I'm not understanding you. I want to do this like a twitter code. I have a bool value in the player data to check if the code has been used or not. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 14 Oct 2015 01:17 AM |
Players.Player.PlayerGui.ScreenGui.Check.Script:4: attempt to call field 'MouseButton1Down' (a userdata value)
what is check?
I used to be a scripter like you, until I took an arrow to the knee |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Oct 2015 02:41 AM |
codes = {FOLLOWING = true, OTHERCODE = true} player = game.Players.LocalPlayer
script.Parent.MouseButton1Down(function() local gui = script.Parent.Parent local input = codes[gui.Input.Text] if input then
-- wrong check here, "FOLLOWING" is not the value of the table index, it's the index itself. -- to fix this, you should replace this statement with this: -- if gui.Input.Text == "FOLLOWING" then
if input == "FOLLOWING" then print("FOLLOWING") elseif input == "OTHERCODE" then print("Other code") end end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Oct 2015 02:57 AM |
Btw it still gives me this error ffs
Players.Player.PlayerGui.ScreenGui.Check.Script:4: attempt to call field 'MouseButton1Down' (a userdata value) |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 02:58 AM |
| ...right. put ":connect" beside that. |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 02:58 AM |
| Oh thanks I forgot about that |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 02:59 AM |
| It still doesn't want to print out anything... |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Oct 2015 12:07 PM |
| My script is still broken, can anyone help? |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 12:56 PM |
| Seriously someone I can't continue without fixing this script |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 01:52 PM |
| Sorry but you need to be more spesific at this point. Otherwise, we can't help you because your script seems to work fine. |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 03:21 PM |
I don't know how much more specific I can get. This is what I want to do
I want to make a twitter code based gui. I have the gui set up, a textbox and a textbutton
I have put a bool value in the player's data to check whether the code has been used or not. I want to make an if function for each code. The script you gave me, doesn't print out ANYTHING when I click the textbutton. I fixed the :connect btw |
|
|
| Report Abuse |
|
|