Hello, is there way to make it where if ur player is super high in the air or low in the air they get teleported to a block?
2 Likes
I made this localscript really quick in studio, just chuck it in StarterCharacterScripts and it should work just fine!
local plr = game:GetService("Players").LocalPlayer -- Gets client's player instance
local char = plr.Character or plr.CharacterAdded:Wait() -- Gets client's character
local runservice = game:GetService("RunService") -- Gets one of my favourite services, RunService. This lets us fire functions every frame!
local teleport_to_part = workspace:WaitForChild("TP_part") -- Replace "TP_part" with the name of whatever part you want the player to teleport to
local max_height = 50 -- Set this to the maximum height you want the player to be able to go
local min_height = -5 -- Set this to the minimum height you want the player to be able to go
runservice.Stepped:Connect(function() -- Fires every frame
if char.HumanoidRootPart.Position.Y < min_height or char.HumanoidRootPart.Position.Y > max_height then -- Checks if the player is over the max height or below the min height
char.HumanoidRootPart.CFrame = teleport_to_part.CFrame -- Teleports the player to the part of choice
end
end)
1 Like