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: MouseButton1Down error

Previous Thread :: Next Thread 
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
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
TimTheTrader is not online. TimTheTrader
Joined: 31 Aug 2015
Total Posts: 27
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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 12:45 AM
It doesn't want to print out anything, any help there?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Oct 2015 12:46 AM
script.Parent.MouseButton1Down:connect(your code
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 12:49 AM
It still doesn't want to print out anything
Report Abuse
cntkillme is not online. 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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
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 is not online. 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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 01:07 AM
Bump?
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 01:12 AM
BUUUUUUUUUUMP
Report Abuse
bigboy77584 is not online. bigboy77584
Joined: 06 Jan 2009
Total Posts: 1003
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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 02:11 AM
check is a textbutton
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 02:52 AM
Thanks Speedy <3
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
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
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
14 Oct 2015 02:58 AM
...right. put ":connect" beside that.
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 02:58 AM
Oh thanks I forgot about that
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 02:59 AM
It still doesn't want to print out anything...
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 03:29 AM
bump
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 12:07 PM
My script is still broken, can anyone help?
Report Abuse
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
14 Oct 2015 12:56 PM
Seriously someone I can't continue without fixing this script
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
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
ByteInfinity is not online. ByteInfinity
Joined: 07 Jun 2014
Total Posts: 459
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
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