Anti Character Void

My map covers a very big area and I think large region 3 areas are performance heavy? This would still require an infinite loop though.

Edit:
I’ll update this thread later, I’m currently still searching for another method that makes use of events.

1 Like

After several tests, I was able to come up with this:

local Character = script.Parent
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local Falling = false

local function OnHumanoidFreeFalling(Active)
	print("Event Fired")
	Falling = Active
	while Falling do
		print("Active")
		if HumanoidRootPart.Position.Y <= -50 then
			print("Teleporting")
			HumanoidRootPart.Anchored = true
			wait(1)
			local Success, Error = pcall(function()
				for i,v in pairs(Character:GetDescendants()) do
					if v:IsA("BasePart") then
						v.Velocity = Vector3.new(0,0,0)
					end
				end
				Character:SetPrimaryPartCFrame(CFrame.new(0,200,0))
			end)
			if Success then
				HumanoidRootPart.Anchored = false
			else
				warn(Error)
			end
		end
		wait(0.1)
	end
end

Humanoid.FreeFalling:Connect(OnHumanoidFreeFalling)

The loop will stop when necessary and makes use of events. I also looped through the character and set all the base parts’ velocity to zero to prevent speeds that will cause issues, I may change this in the future. If anyone sees any potential imporvements, I’d be happy to know them :slight_smile:

6 Likes