Hello! I’ve been racking my brain trying to figure this issue out for around an hour and still couldn’t find any way to fix this, so I thought I’d take it to the devforum.
Basically, whenever I press a key it equips a tool and plays an animation and then when you press that key again, it plays the same animation but in reverse, the issue is that it has 1 or 2 frames in-between the animations where the tool goes to its motor6d initial position (watch the attached video for the showcase). Tthe tool is held by the player with a motor6d from the torso (Part 0) to the “FakeHandle” (Part 1). The 1 or 2 frames however much it is are very noticeable and those are the issue I’m trying to address with this. Please help if you can
Code:
local char=plr.Character or plr.CharacterAppearanceLoaded:Wait()
local Hum=char:WaitForChild("Humanoid")
local Animator=Hum:WaitForChild("Animator")
local tool=script.Parent
local animSWING=Animator:LoadAnimation(tool.SWING)
local animIDLE=Animator:LoadAnimation(tool.IDLE)
local animREADY=Animator:LoadAnimation(tool.READY)
local m6d
local IsSwinging=false
local RE=game.ReplicatedStorage.RemoteEvent
local CAS=game:GetService("ContextActionService")
local equipped=false
local function equiptool(actionName, inputState, inputObj)
if inputState==Enum.UserInputState.Begin then
tool.Parent=char
equipped=not equipped
if equipped==false then
animREADY:Play(0.100000001, 1, -1)
elseif equipped==true then
m6d=Instance.new("Motor6D")
m6d.Part0=char.Torso
m6d.Part1=script.Parent.Fake
m6d.Parent=char.Torso
animREADY:Play()
end
end
end
local function Markers(name)
if name=="END" and equipped==true then
animREADY:AdjustSpeed(0)
elseif name=="START" and equipped==false then
animREADY:AdjustSpeed(0)
end
end
animSWING.Ended:Connect(function()
IsSwinging=false
end)
local function Swing()
IsSwinging=true
local db=false
tool.Hit.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") and db==false and IsSwinging==true then
local hrp=hit.Parent:FindFirstChild("HumanoidRootPart")
RE:FireServer(hrp)
hrp.AssemblyLinearVelocity=hrp.CFrame.LookVector*-50
db=true
task.wait(1)
db=false
end
end)
animSWING:Play()
end
script.Parent.Activated:Connect(Swing)
CAS:BindAction("equip",equiptool, false, Enum.KeyCode.G)
animREADY.KeyframeReached:Connect(Markers)
and then the tool hierarchy is:
everything in the red area are parts welded to the "Fake" "Fake" is what everything is welded to "FakeHandle" would be the handle of the tool but I disabled it, it has a motor6d that has part 0 as "Fake" and then part1 as "FakeHandle"
attached gif: RobloxStudioBeta PTLHfR0Qdh - Gifyu (the problem happens 3 times in total but you can only see it once very well because of the fps of the gif, the 1st time it’s clear enough to understand the issue though.