How can I get my arms to view my camera?

I’ve got these guns I’m messing around with. I’m trying to get the gun which is attached to my arm so essentially my arm to rotate and follow my mouse wherever it goes. To simulate aiming around the screen with a gun

https://gyazo.com/13d8bd122379f09ff37e1bbdc1bdb663

Currently the gun stays where it is leveled.

1 Like

You do not really seem to be asking a question here, but based on the title of your post, I assume you want the arms to show in first person mode. To achieve this, I suggest changing the left and right arm’s LocalTransparencyModifier property. This is handled through a LocalScript on the client. You can find more information about this here:

https://developer.roblox.com/en-us/api-reference/property/BasePart/LocalTransparencyModifier

As for animating the gun (allowing it to rotate based on the camera’s orientation), this is a much more complex concept. You will have to do a lot of research for this, but I suggest you use the following DevForum post as a guide. I personally used this one when I was researching this topic myself and can assure you it is very helpful.

You can use this:

Arm.CFrame = CFrame.new(Arm.Position, Mouse.hit.p)

This makes the arm looks at the mouse’s position and doesn’t effect the arms position.

1 Like

I know that you know that there is much more to local animation than that one line of code. This is not helpful to him if he truly wants to understand this complex topic.

I mean, it works. It’s simple, efficient and consistent.

1 Like

Yea I already used that topic, it mentions nothing about gun CFrame for arms.

How do I get mouse of a player if this script is running in a tool?

I think I remember an old function that was like script.Parent:GetPlayerFromCharacter() ?

This is my script, not working D:

Mouse = game.Players.LocalPlayer:GetMouse()

Character = game.Players.LocalPlayer:WaitForChild("Character")

while true do

wait()

Character.RightUpperArm.CFrame = CFrame.new(Character.RightUpperArm.Position, Mouse.hit.p)

end

So this just yeets my character, is there a better way to go about this? I’ve got my “fake arms” welded to upper arms.

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local character = player.Character

Mouse = game.Players.LocalPlayer:GetMouse()

if not character or not character.Parent then

character = player.CharacterAdded:wait()

end

while true do
wait()
character.RightUpperArm.CFrame = CFrame.new(character.RightUpperArm.Position, Mouse.hit.p)
end

Make sure the arms are non collidable.

Try out Players | Roblox Creator Documentation

Didn’t work → Inside a LocalScript in the Tool


local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
Mouse = game.Players.LocalPlayer:GetMouse()

if not character or not character.Parent then
	character = player.CharacterAdded:wait()
end

while true do
	wait()
	character.RightUpperArm.CanCollide = false
	character.LeftUpperArm.CanCollide = false
	character.LeftLowerArm.CanCollide = false
	character.RightLowerArm.CanCollide = false
	character.LeftHand.CanCollide = false
	character.RightHand.CanCollide = false
	character.RightUpperArm.CFrame = CFrame.new(character.RightUpperArm.Position, Mouse.hit.p)
end

You have to you use CollisionGroups. Just making the parts non-collidable will not be enough.

How is that done? I’ve never heard of that before.

You can search on the roblox developer website - BasePart | Roblox Creator Documentation

https://gyazo.com/3ae2674ae5c02b5760dcbe3aca61d382
I added a collision group called “Arms”
I unchecked “default” I assume that turns off collision for all other objects? So it wont collide with anything?

Not having any such luck though sadly. Still same issue.

So I put this script in my starter character scripts.

local PhysicsService = game:GetService("PhysicsService")

local arms = "Arms"

character = script.Parent

PhysicsService:SetPartCollisionGroup(character.LeftUpperArm, arms)
PhysicsService:SetPartCollisionGroup(character.LeftLowerArm, arms)
PhysicsService:SetPartCollisionGroup(character.LeftHand, arms)
PhysicsService:SetPartCollisionGroup(character.RightUpperArm, arms)
PhysicsService:SetPartCollisionGroup(character.RightHand, arms)
PhysicsService:SetPartCollisionGroup(character.RightLowerArm, arms)

My arm CFrame script (Inside LocalScript)

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
Mouse = game.Players.LocalPlayer:GetMouse()

if not character or not character.Parent then
	character = player.CharacterAdded:wait()
end

while true do
	wait()

	character.RightUpperArm.CFrame = CFrame.new(character.RightUpperArm.Position, Mouse.hit.p)
end

anyone have some ideas to do this?