I have a bit of setup before I completely delve into the problem: I’m making a script that will automatically return you to where you were last on the ground if you fell off the map.
you can’t normally jump in this game so whenever you fall off, you usually just appear at the very edge of the part you fell off of. I need the part to be further from the edge of the part so that you don’t accidently fall off again
So far i haven’t found any solutions to this problem.
TECHNIQUELY I could just make a raycast in all 4 cardinal directions, but i fell like that’s the wrong way to do this
heres the code i have right now (I removed alot but its still basically the what it show in the video)
local Character = script.Parent
local HumanoidRootPart:Part = Character:WaitForChild("HumanoidRootPart")
local RunService = game:GetService("RunService")
local LastGroundPosition = Vector3.new()
function BeReady()
local Perams = RaycastParams.new()
Perams.FilterDescendantsInstances = {Character, workspace.Hitboxes}
Perams.FilterType = Enum.RaycastFilterType.Exclude
local Raycast = workspace:Raycast(HumanoidRootPart.Position, Vector3.new(0,-6,0), Perams)
if Raycast then
LastGroundPosition = Raycast.Position
end
end
function Save()
--DamageFunction.Scripts.Normal(Humanoid, 2, "Enviorment", nil) Irrelevant script, + ill update it later
Character:PivotTo(CFrame.new(LastGroundPosition+Vector3.new(0,3,0)))
end
RunService.Heartbeat:Connect(function()
BeReady()
if HumanoidRootPart.Position.Y <= -10 then
--KnockbackScript:Stop() Another irrelevant script
Save()
end
end)
