|
| 11 Oct 2013 10:46 PM |
| I have an arm in Camera that I want to move according to where the mouse is. So if the mouse is at the top of the screen, I want the arm to point upward... how can I do this? |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2013 10:48 PM |
| I tried motor1:SetDesiredAngle(math.atan(mouse.Y)) btw |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2013 10:52 PM |
| and the arm only moves at like the top 10 pixels of the screen |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 11 Oct 2013 10:57 PM |
(In a LocalScript)
local part = Workspace.Part repeat wait() until game.Players.LocalPlayer local player = game.Players.LocalPlayer local mouse = player:GetMouse()
mouse.Move:connect(function() local scr = Instance.new("ScreenGui",player.PlayerGui) local maxy = scr.AbsoluteSize.Y/2 scr:Destroy() part.CFrame = CFrame.new(part.Position)*CFrame.Angles((maxy-mouse.Y)/maxy*math.pi/2,0,0) end) |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2013 11:03 PM |
I'm using Motor6D though :p there's a bunch of other lines but they're not important... I need to get the right angle at motor1:SetDesiredAngle()
-- menu.Event:connect(function() local fakeBody, motor1 = menuAnim() mouse.Move:connect(function() local y = mouse.Y motor1:SetDesiredAngle(math.atan(y)) end) end) |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 11 Oct 2013 11:25 PM |
local scr = Instance.new("ScreenGui",player.PlayerGui) local maxy = scr.AbsoluteSize.Y/2 scr:Destroy() motor1:SetDesiredAngle((maxy-mouse.Y)/maxy*math.pi/2)
Note though, that player needs to be defined. Also, don't put connections to functions inside of other functions. That's silly. |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2013 11:28 PM |
Thanks! And player is defined, I only posted a portion of the script.. and why can't I put connections into other functions? It works fine! |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 11 Oct 2013 11:31 PM |
| In this case it would, but if I'm not mistaken you're basically creating a new function every time 'Event' is called from menu - one that's never disconnected. Therefore, is 'Event' was called twice, the mouse.Move function would also be called twice, because it's still there from the first call of 'Event', if that makes any sense. |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2013 11:32 PM |
no, I didn't include it in the script I showed, but the event disconnects itself because I have it like
local loop = mouse.Move:connect(function() if not something then loop:disconnect() end end) |
|
|
| Report Abuse |
|
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
| |
|