Is there a way for a player to not be able to fall into the void? For example, in Minecraft, when you crouch you can’t fall off of that block you are on unless you uncrouch or jump.
If you have ever done anything like this please say how or if not provide ideas.
Also, I am not 100% sure this is the right category for this topic.
I do not speak English, remember that when reading
Everything the people mentioned above is true
Invisible walls about whatever you are on
Try this code if you don’t want to use Invisible walls about whatever you are on
The player is unable to fall into a void
This code when placed inside a LocalScript in StarterPlayer in StarterCharacterScripts
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Root = script.Parent:WaitForChild("HumanoidRootPart")
local Humanoid = script.Parent:WaitForChild("Humanoid")
local model = script.Parent
local Enabled = false
local function onModelTouched(part)
if part:IsDescendantOf(model) then return end
--print(model:GetFullName() .. " was touched by " .. part:GetFullName())
if part.Name == "Head" then
Enabled = false
elseif part.BrickColor == BrickColor.new("New Yeller") then
Enabled = false
elseif part.Size == Vector3.new(7, 7, 7) then
Enabled = false
else
Enabled = true
end
end
for _, child in pairs(model:GetChildren()) do
if child:IsA("BasePart") then
child.Touched:Connect(onModelTouched)
end
end
mouse.KeyDown:connect(function(key)
if key == "e" then
local bodyPosition = Root:FindFirstChild("BodyPosition")
if bodyPosition then
bodyPosition:Destroy()
end
end
end)
Humanoid.StateChanged:Connect(function(oldState, newState)
--print(oldState, newState)
if oldState == Enum.HumanoidStateType.Jumping and newState == Enum.HumanoidStateType.Freefall then
local bodyPosition = Root:FindFirstChild("BodyPosition")
if bodyPosition then
bodyPosition:Destroy()
end
end
if newState ~= Enum.HumanoidStateType.Freefall then
local bodyPosition = Root:FindFirstChild("BodyPosition")
if bodyPosition then
bodyPosition:Destroy()
end
end
end)
function onFreeFall()
if Enabled == true then
if not Root:FindFirstChild("BodyPosition") then
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.MaxForce = Vector3.new(0, math.huge, 0)
bodyPosition.P = 10000
bodyPosition.D = 1250
bodyPosition.Parent = Root
bodyPosition.Position = Root.Position
end
end
end
Humanoid.FreeFalling:connect(onFreeFall)
If it doesn’t work properly, tell me yen the problem