Hi, I have recently started working on a new project and for a hitbox I have been using a part and GetTouchingParts() function. However after I spawn in the part and promptly destroy it there is still a weird physics effect were the player will gain a lot of velocity when turning as if the block was still there? Is there a way to remove it or am I just forgetting something? This is my code
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Animation = script:WaitForChild("Fall")
local debounce = false
ReplicatedStorage.AttackHitboxOne.OnServerEvent:Connect(function(player)
if debounce == false then
debounce = true
local Humanoid = player.Character.Humanoid
if Humanoid.FloorMaterial ~= Enum.Material.Air then
local part = Instance.new("Part")
local offset = Vector3.new(0, 0, -5)
part.Size = Vector3.new(10,12,15)
part.Transparency = 1
part.Name = "Fall Hitbox"
part.CanCollide = true
part.Anchored = true
part.Parent = workspace
part.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(offset)
player.Character.HumanoidRootPart.Anchored = true
local Anim = Humanoid:LoadAnimation(Animation)
Anim:Play()
wait(0.4)
for _, touching in pairs(part:GetTouchingParts()) do
if touching.Parent then
if touching.Parent.Name:match("Enemy") then
if not touching.Parent:FindFirstChild("AttackScript") then
touching.Parent:Destroy()
end
end
end
end
wait(0.4)
Anim:Stop()
player.Character.HumanoidRootPart.Anchored = false
part:Destroy()
end
end
debounce = false
end)