Hello, I am trying to make a gun system which moves the character up and down depending on where the gun is pointed. To solve this, and to make it replicate to all clients, I am setting the timeposition to where the mouse is, with 2 being all the way up and 0 being all the way down. The Motor6D used for the guns is created by the server.
script.Parent.Equipped:Connect(function()
Animator = Humanoid:WaitForChild("Animator")
IsEquipped = true
Character.Humanoid.AutoRotate = false
if game.Players.LocalPlayer.Character.RightHand:FindFirstChild("WeaponMotor") ~= nil then
game.Players.LocalPlayer.Character.RightHand.WeaponMotor.Part1 = script.Parent.Base
end
local BodyGyro = script.BodyGyro:Clone()
BodyGyro.Parent = Torso
BodyGyro.Name = "GunGyro"
Move()
ButtonDown = false
Deb = false
EquipAnim:Play(.2)
EquipAnim.Stopped:Wait()
if IsEquipped then
Idle:Play(0)
Idle:AdjustSpeed(.001)
Idle.TimePosition = math.clamp(Mouse.Hit.LookVector.Y+1,0,1.9)
end
end)
function Move()
Idle:AdjustSpeed(0.001)
local toTween = Idle
local tweenInfo = TweenInfo.new(.05, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) -- Change to your liking
local goal = {}
goal.TimePosition = math.clamp(Mouse.Hit.LookVector.Y+1,0,1.9)
local tween = game:GetService("TweenService"):Create(toTween, tweenInfo, goal)
tween:Play()
if Torso:FindFirstChild("GunGyro") ~= nil then
Torso:WaitForChild("GunGyro").CFrame = CFrame.new(Torso.Position, Mouse.Hit.p)
end
end
RS.RenderStepped:Connect(Move)
Whenever I unequip one gun and immediately go to another, or just spam equip and unequip on a single gun, the idle animation stops running in favor of the normal tool holding animation. Is there a way to fix this?