I made some animations for a gun, I want to turn it into an fps but I’m not sure how to integrate a view-model (arms and gun) into first person just on the client side, like in this video:
Any help appreciated!
I made some animations for a gun, I want to turn it into an fps but I’m not sure how to integrate a view-model (arms and gun) into first person just on the client side, like in this video:
Any help appreciated!
A script like this would make the shoulders Motor6Ds move on the Y axis depending on the mouses position.
local CFnew, CFang = CFrame.new, CFrame.Angles
local asin = math.asin
local mouse = game.Players.LocalPlayer:GetMouse()
script.Parent:WaitForChild("Torso")
local c = coroutine.create(function()
while wait(.1) do
if game.Players.LocalPlayer.Name == script.Parent.Name then
local T = "Torso"
if script.Parent:WaitForChild(T) then
local T1 = "Left Shoulder"
if script.Parent:WaitForChild(T):WaitForChild(T1) then
local R = script.Parent:WaitForChild(T):WaitForChild(T1).C0.Rotation
local T = script.Parent:WaitForChild(T):WaitForChild(T1)
local cframe = CFnew(-1, .5, 0) * CFang(-asin((mouse.Origin.p - mouse.Hit.p).Unit.y), -1.55, R.Z)
local C0 = cframe
T.C0 = C0
end
local T1 = "Right Shoulder"
if script.Parent:WaitForChild(T):WaitForChild(T1) then
local R = script.Parent:WaitForChild(T):WaitForChild(T1).C0.Rotation
local T = script.Parent:WaitForChild(T):WaitForChild(T1)
local cframe = CFnew(-1, .5, 0) * CFang(-asin((mouse.Origin.p - mouse.Hit.p).Unit.y), 1.55, R.Z)
local C0 = cframe
T.C0 = C0
end
end
end
end
end)
coroutine.resume(c)
This script can be improved, but this is just some old code I wrote for client. It might not work.
Anyway to make it look at cameras direction instead of mouse direction?
I am not sure how to make it directional to the camera.