Hello, i am making a “super power” type thing in my game, but, after the animation is played, the character has weird movement, especially when rotating.
I’ve pinpointed the fact that it’s the animation’s fault, as when i run the same code, but the Animation:Play() line of code is commented out, i don’t get the offset.
How would i fix this?
Code
local ts = game:GetService("TweenService")
local deb = game:GetService("Debris")
local rs = game:GetService("RunService")
local db = false
script.Attack.OnServerEvent:Connect(function(plr)
if plr.Character == script.Parent then
if db == false then
db = true
--script.Parent.HumanoidRootPart.Anchored = true
local anim = script.Parent.Humanoid.Animator:LoadAnimation(game.ReplicatedStorage.Animations.ShortRangeBeam)
anim:Play()
task.wait(1.15)
local beam = game.ReplicatedStorage.AttackModels.ShortRangeBeam:Clone()
beam.Parent = workspace.Attacks
beam.Anchored = false
local weld = Instance.new("Weld")
weld.Part0 = script.Parent["Left Arm"]
weld.Part1 = beam
weld.C0 = script.Parent["Left Arm"].LeftGripAttachment.CFrame
weld.C1 = beam.Attachment.CFrame
weld.Parent = script.Parent["Left Arm"]
deb:AddItem(weld,1.5)
deb:AddItem(beam,1)
beam.Touched:Connect(function() end)
local dmgdeb = false
local beamer = rs.Stepped:Connect(function()
if dmgdeb == false then
for _,h in pairs(beam:GetTouchingParts()) do
if h.Parent and h.Parent:FindFirstChild("Humanoid") and h.Parent ~= script.Parent then
dmgdeb = true
h.Parent.Humanoid:TakeDamage(3)
local bodypos = Instance.new("BodyPosition")
bodypos.Position = beam.Position
bodypos.P = 5000
bodypos.MaxForce = Vector3.new(1,1,1)*250000
bodypos.Parent = h.Parent.HumanoidRootPart
game.Debris:AddItem(bodypos,0.15)
h.Parent.Humanoid.PlatformStand = true
delay(0.15,function()
h.Parent.Humanoid.PlatformStand = false
end)
task.wait(0.1)
dmgdeb = false
end
end
end
end)
task.wait(0.5)
beam.Anchored = true
weld:Destroy()
ts:Create(beam,TweenInfo.new(0.5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{Size = Vector3.new(0,0,18),Transparency = 0.5}):Play()
task.wait(0.25)
script.Parent.HumanoidRootPart.Anchored = false
beamer:Disconnect()
task.wait(5)
db = false
end
end
end)