tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 04 Jun 2014 06:39 PM |
I'm making a tool version of the move tool... it works great except for the fact that you gotta click constantly to keep moving something. How would I make it in which it will keep going as long as the button is held down? Here's the code:
local Mouse = game.Players.LocalPlayer:GetMouse()
function bdown() if Mouse.Target.Locked == false then Mouse.Target.Position = Mouse.Hit.p end end function sel(m) m.Button1Down:connect(bdown) end script.Parent.Equipped:connect(sel) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Jun 2014 06:47 PM |
local Mouse = game.Players.LocalPlayer:GetMouse() local Down = false
function bdown() if Mouse.Target.Locked == false then Mouse.Target.Position = Mouse.Hit.p end end function sel(m) m.Button1Down:connect(function() if Down return end Down = true while Down do bdown() wait() end end m.Button1Up:connect(function() Down = false end) end script.Parent.Equipped:connect(sel) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2014 06:51 PM |
You would use the button1down event, and the button1up event, and the mouse's move event.
m=game.Players.LocalPlayer:GetMouse(); variable=false;
m.Button1Down:connect(function() target = m.Target if target then variable = true m.Move:connect(function() if variable == true then target.CFrame = CFrame.new(m.hit.X,m.hit.Y+(target.Size.Y/2),m.hit.Z) end end) end m.Button1Up:connect(function() variable = false end) end) |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 04 Jun 2014 07:00 PM |
| It works now... but how would I make it always welded to the floor? I'm trying to make a clone of the classic move tool, but in tool form. |
|
|
| Report Abuse |
|
|