Hello devs! I am working on flinding script :
local Char = script.Parent
local Root = Char:WaitForChild("HumanoidRootPart")
local MaxForceValue = 1000
function getClosestPlayer()
local closest_player, closest_distance = nil, 70
for _, player in pairs(workspace:GetChildren()) do
if player:IsA("Model") then
if player:FindFirstChildWhichIsA("Humanoid") and player ~= Char then
if player.Humanoid.Health > 0 then
local distance = (Root.Position - player.HumanoidRootPart.Position).Magnitude
if distance < closest_distance then
closest_player = player
closest_distance = distance
end
end
end
end
end
return closest_player, closest_distance
end
while wait() do
local player = getClosestPlayer()
if player then
if not player.HumanoidRootPart:FindFirstChild("Force") then
local Force = Instance.new("BodyVelocity")
Force.Name = "Force"
Force.MaxForce = Vector3.new(MaxForceValue,MaxForceValue,MaxForceValue)
Force.Velocity = (-player.HumanoidRootPart.CFrame.lookVector) * 100
Force.Parent = player.HumanoidRootPart
end
end
end
and it keeps removing Baseplate even if its not supposed to happen
Hope you can help me.