janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 10 May 2013 02:42 PM |
It's a bit complicated, but I'm trying to make a tool that'll change NumberValues in a given brick (Named "scanner") I don't know how to use the mouse at all, but basically I need to click on any brick named "scanner" and run something like this:
onClicked() if scanner.num1 == 0 then scanner.num1 = 5 elseif scanner.num1 ~= 0 then if scanner.num2 == 0 then scanner.num2 = 5 elseif scanner.num2 ~= 0 then if scanner.num3 == 0 then scanner.num3 = 5
Basically, if the NumberValues == 0, change one to 5, if they all ~= 0, leave it alone. Also, if one already == 5, act the same way. Can someone help me do the mouse part, please?
|
|
|
| Report Abuse |
|
|
|
| 10 May 2013 02:43 PM |
function click() if mouse.Target and mouse.Target.Name == "PutTheNameOfTheBrickHere" end
script.Parent.MouseButton1Down:connect(click)
--Something like that |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 10 May 2013 02:45 PM |
| Thanks. Will the rest of the script that I posted work properly, you think? |
|
|
| Report Abuse |
|
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 10 May 2013 03:03 PM |
Okay, so I have this:
BP=script.Parent.BP x=game.Workspace.Quaternary.num1.Value y=game.Workspace.Quaternary.num2.Value z=game.Workspace.Quaternary.num3.Value q=game.Workspace.Quaternary.num4.Value j=game.Workspace.Quaternary.num5.Value function click() if mouse.Target and mouse.Target.Name == "Quaternary" then if x==0 then x=BP elseif x~=0 then if y==0 then y=BP elseif y~=0 then if z==0 then z=BP elseif z~=0 then if q==0 then q=BP elseif q ~= 0 then j=BP elseif j~=0 then j=j end end end end end end
script.Parent.MouseButton1Down:connect(click)
I guess it's a bit messy, but can you see what I'm trying to do? It's not changing the numbervalues at all, for some reason. The only related output I can find is this: "13:00:53.064 - MouseButton1Down is not a valid member of Tool"
I tried with a hopperbin too, and got this: "13:02:36.410 - MouseButton1Down is not a valid member of HopperBin"
Help? |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 10 May 2013 03:04 PM |
Apparently the problem is with the last line:
.Parent.MouseButton1Down:connect(click)
What am I doing wrong? |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 10 May 2013 03:09 PM |
| Should I have a ClickDetector or something similar in the brick? |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
| |
|
|
| 10 May 2013 04:51 PM |
At the top of the script put this
function click()
(If you haven't already) |
|
|
| Report Abuse |
|
|
|
| 10 May 2013 04:51 PM |
never mind, I didn't see the function click() in the script
~My bad |
|
|
| Report Abuse |
|
|
|
| 10 May 2013 04:52 PM |
Oh! This is in a HopperBin so it has to be Button1Down NOT MouseButton1Down
http://wiki.roblox.com/index.php/HopperBins |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 10 May 2013 10:45 PM |
Okay, so now I have this:
wait(.1) BP=script.Parent.BPx.Value x=game.Workspace.Quaternary.num1.Value y=game.Workspace.Quaternary.num2.Value z=game.Workspace.Quaternary.num3.Value q=game.Workspace.Quaternary.num4.Value j=game.Workspace.Quaternary.num5.Value myMouse = game.Players.LocalPlayer:GetMouse() myMouse.Button1Down:connect(function() end) if myMouse.Target then end local part= myMouse.Target if part.Name == "Quaternary" then end print ("working?") if x==0 then x=BP elseif x~=0 then if y==0 then y=BP end--Add an end elseif y~=0 then if z==0 then z=BP end--Add an end elseif z~=0 then if q==0 then q=BP end--Add an end elseif q ~= 0 then j=BP elseif j~=0 then j=j end print("Works!")
It's doing both prints right when the tool enters, it doesn't need me to click for some reason. It's also not changing num1. |
|
|
| Report Abuse |
|
|
|
| 11 May 2013 04:26 AM |
myMouse?
It should be 'mouse' |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 11 May 2013 09:05 AM |
| That's just a variable name.. |
|
|
| Report Abuse |
|
|