I’m trying to stop the bodyvelocity from moving once it clears a certain amount of distance but it keeps moving. I’ve tried to stop its movement by anchoring the player and making the BV maxforce and velocity 0 but it doesn’t seem to work.
local rp = game:GetService("ReplicatedStorage")
local CycloneCrash = rp:WaitForChild("CycloneCrash")
local animations = script:WaitForChild("Animations")
local meshes= script:WaitForChild("MeshesCC")
local speed = 500
local damage = 30
CycloneCrash.OnServerEvent:Connect(function(Player, direction)
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local humrp = Character:WaitForChild("HumanoidRootPart")
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local goal = {CFrame = humrp.CFrame + Vector3.new(0,40,0)}
local TweenStart = TweenService:Create(humrp,Info,goal)
TweenStart:Play()
humrp.Anchored = true
wait(1.5)
local Vel = Instance.new("BodyVelocity")
Vel.Parent = humrp
Vel.MaxForce = Vector3.new(2e4,2e4,2e4)
wait(.5)
Vel.Velocity = direction.lookVector * speed
humrp.Anchored = false
local oldPos = goal
local limitBarrier = 60
local debris = game:GetService("Debris")
if (humrp.CFrame - oldPos).Magnitude >= limitBarrier then
Vel.Parent = humrp
Vel.Velocity = Vector3.new(0,0,0)
Vel.MaxForce = Vector3.new(0,0,0)
humrp.Anchored = true
local hitboxFold = Instance.new("Folder",workspace)
hitboxFold.Name = Player.Name.." hitbox"
debris:AddItem(hitboxFold,2)
local Hitbox1 = meshes:WaitForChild("HitboxCC"):Clone()
Hitbox1.Size = Vector3.new(16,16, 16)
Hitbox1.CFrame = humrp.CFrame
Hitbox1.CanCollide = false
Hitbox1.CanTouch = true
Hitbox1.Anchored = true
Hitbox1.Archivable = true
Hitbox1.Locked = false
Hitbox1.CastShadow = false
Hitbox1.Transparency = 1
Hitbox1.Parent = hitboxFold
Hitbox1.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Character)then
local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
if Humanoid.Health > 0 then
hitboxFold:Destroy()
Humanoid:TakeDamage(damage)
humrp.Anchored = false
end
end
end
end
end)
end
end)