I’m trying to make a script that, it sets a hand view model position, and, in the same script, i want that when the player shoots, it occurs a recoil.
The problem is that, in the script, instead of changing the Y axis from the angle, it changes the Y axis from the position.
Here is the script:
local module = {}
local Camera = workspace.CurrentCamera
local Modules = game.ReplicatedStorage.Modules
local OffsetAngles = CFrame.Angles(0, 0, 0)
function module:SetHands(Hands)
local NewHands = Hands:Clone()
NewHands.Parent = Camera
NewHands["Left Arm"].CanCollide = false
NewHands["Right Arm"].CanCollide = false
return NewHands
end
function module:UpdateHands(Hands)
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
if Camera:FindFirstChild(Hands.Name) ~= nil then
if Humanoid.Health == 0 then
Camera[Hands.Name]:Destroy()
else
Hands["Left Arm"].CanCollide = false
Hands["Right Arm"].CanCollide = false
Camera[Hands.Name]:SetPrimaryPartCFrame((Camera.CFrame * CFrame.new(.25, -2, 0.3)) * OffsetAngles)
end
end
end
Modules.GunModule.Shoot.Event:Connect(function(Time)
-- Recoil
for i = 1, 5 do
OffsetAngles += Vector3.new(0, math.rad(i), 0)
task.wait(.02)
end
task.wait(.3)
for i = 1, 5 do
OffsetAngles += Vector3.new(0, -math.rad(i), 0)
task.wait(.02)
end
end)
return module
Since now, i’ve already checked if its change the orientation from any part from the hand, but no results.