|
I want to have both my arms follow wherever my mouse points when I am in first person mode. I have been trying to do this for 2 days without any luck. Please help. |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
Look at some fre. models. |
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
local dir = (MOUSE.Hit.p - (TORSO.Position + Vector3.new(1.5, 0.5, 0))).unit
local angle = math.asin(-dir.y)
SHOULDERWELD.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) -- maybe not necessary
SHOULDERWELD.C1 = CFrame.new(-0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, math.pi/2, 0)
That'd probably do it if you defined all the variables I capitalized for you and ran it on a loop |
|
|
what is the variable for SHOULDERWELD? |
|
|
Because i need both arms to follow the mouse |
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
Then just do the bit with the SHOULDERWELD's twice, one for each shoulder.
The variable is either the actual shoulder joint or a custom shoulder weld, if you don't want the arms to still move with walking and jumping and all that. |
|
|
I have it in startergui as a local script and it doesn't work... What should I do? |
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
What I posted is really just a framework so you can see the math...
You have to implement it yourself - make sure you defined all the variables |
|
|
i don't understand trig... |
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
You don't have to, I gave all the math to you. |
|
|
Can you at least tell me what I did wrong?
local mouse = Game.Players.LocalPlayer:GetMouse()
repeat wait() until Game.Players.LocalPlayer.Character
local torso = Game.Players.LocalPlayer.Character:WaitForChild("Torso")
local shoulderweld = Game.Players.LocalPlayer.Character.Torso:WaitForChild("Right Shoulder")
local shoulderweld2 = Game.Players.LocalPlayer.Character.Torso:WaitForChild("Left Shoulder")
i = 10
while 1 == 10 do
local dir = (mouse.Hit.p - (torso.Position + Vector3.new(1.5, 0.5, 0))).unit
local angle = math.asin(-dir.y)
shoulderweld.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) -- maybe not necessary
shoulderweld.C1 = CFrame.new(-0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, math.pi/2, 0)
shoulderweld2.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) -- maybe not necessary
shoulderweld2.C1 = CFrame.new(-0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, math.pi/2, 0)
end |
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
while 1 == 10 do
1 never equals 10 silly. Also, there's no wait in that loop anyways.
Also, I forgot that you needed to change the CFrames for the Left Shoulder. Here's the loop redone:
while wait() do
local dir = (mouse.Hit.p - (torso.Position + Vector3.new(1.5, 0.5, 0))).unit
local angle = math.asin(-dir.y)
shoulderweld.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0) -- maybe not necessary
shoulderweld.C1 = CFrame.new(-0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, math.pi/2, 0)
shoulderweld2.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0) -- maybe not necessary
shoulderweld2.C1 = CFrame.new(0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, math.pi/2, 0)
end
The left arm may be backwards, no idea. |
|
|
i have it in startergui and nothing happens |
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
This works in StarterGui (Note: the arms will not go behind your head unless you/I put in a special case for it):
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local mouse = player:GetMouse()
local torso = player.Character:WaitForChild("Torso")
local right = torso:WaitForChild("Right Shoulder")
local left = torso:WaitForChild("Left Shoulder")
while wait() do
local dir = (mouse.Hit.p - (torso.Position + Vector3.new(1.5, 0.5, 0))).unit
local angle = math.asin(-dir.Y)
right.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
right.C1 = CFrame.new(-0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, math.pi/2, 0)
left.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
left.C1 = CFrame.new(0.5,0.5,0) * CFrame.Angles(angle - math.pi/2, -math.pi/2, 0)
end |
|
|
Now I start doing the worm and spasming on the ground because of the arms
|
|
MHebesJoin Date: 2013-01-04 Post Count: 2278 |
Not in my solo test :P |
|
|
hbu come to my game to test it out and see what happens |
|
|
it still doesn't work after not moving the left shoulder... i seriously need help |
|
|
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player.Character
local character = player.Character
local torso = character.Torso
local ls = torso['Left Shoulder']
local rs = torso['Right Shoulder']
while true do
wait()
local cframe = CFrame.new(torso.Position,mouse.Hit.p)
local cframe = cframe:inverse()*torso.CFrame
local cframe = cframe-cframe.p
ls.C0 = cframe:inverse()*CFrame.Angles(math.pi/2,0,0)
rs.C0 = cframe:inverse()*CFrame.Angles(math.pi/2,0,0)
end
This is technically what you requested. Edit it to your needs. (No trigonometry needed)
Alt. of Jetta765214 |
|
|
this puts my arms in the middle of my body and it spasms |
|
|
wiki.roblox.com
You seem to lack common intelligence, please just search around the wiki for scripting tutorials.
Roblox scripting is not a thing you can do in 2 minutes and expect something amazing happening for beginners. |
|