(Hopefully This doesn't sound like a request, I'm just trying to get an example)
How would I make it so that whenever I press down a key, it makes the character's arms change position and rotation?
If I use Vector3, the arms just detach.
I've heard that CFraming won't make them detach, but I'm not sure how to use it.
Can someone provide a simple script that moves the arm over a few studs so I can use it as a base for the actual script? Or would that be too much of a request?
You could use the animations, they're free to make. If you still don't get it, then there are Moter6Ds in the player's character. If you want to move the right arm a few studs forward then:
Like most joints, joints have C0 and C1. These mean CFrame0 and CFrame1 for part0 and part1. We need to move C1 3 studs forward, we can use lookVector so we know where is forward for the player.
Is like Vector3 but it's more complicated, you can change angles and there is lookVector and many other thing that aren't useable with Vector3. Here are the features we will be using with CFrame:
Will determine where the part's front face is facing.
print(workspace.Part.CFrame.lookVector) --Will print a Vector3 of where it is facing.
Angles are useful and with CFrame.Angles
you can change the CFrame of the Part AND Rotate it!
workspace.Part.CFrame = CFrame.new(0,10,4) * CFrame.Angles(0,math.rad(45), math.rad(5))
Now you have to use math.rad()
when changing the Angles to something, BUT you don't have to do that if you do something like this:
workspace.Part.CFrame = CFrame.new(0,10,4) * CFrame.Angles(0, 141.371669/pi, 15.7079633/pi)
I think it's like that. You don't need to do the pi
way but make sure you use math.rad()
. If it isn't right, I didn't learn this in school yet!
UserInputService is a service that seeks for any sign of input(clicking, scrolling, typing)
local uis = game:GetService("UserInputService") uis.InputBegan:connect(function(input, chat) --Input began is like KeyDown, but not deprecated. if input.KeyCode == Enum.KeyCode.E and not chat then --Code end end)
--LocalScript local uis = game:GetService("UserInputService") local plyr = game:GetService("Players").LocalPlayer plyr.CharacterAdded:connect(function(char) local t = char:WaitForChild("Torso") local motor = char:WaitForChild("Right Shoulder") uis.InputBegan:connect(function(input, chat) if input.KeyCode == Enum.KeyCode.E and not chat then motor.C1 = motor.C1+motor.C1.lookVector*3 end end) end)
Hope it helps!