I’m making a script that, after a certain amount of seconds pass by, resets terrain to restore it when players destroy it. However, the terrain is a large block, so if players dig a hold inside it, go in the hole when it’s resetting, players will be inside the terrain. My game is a fighting game, so players will be fully protected while in the terrain. They can freely move in the terrain, and have no trouble simply walking out of it, but they would still be protected while inside it. I’m trying to prevent this by teleporting players outside of the terrain when they are in it, however I am having some issues with this.
I’m trying to call :GetTouchingParts()
on the terrain, but it errors, saying that it is not a valid member of terrain.
This is the script. It is in ServerScriptService.
local terrain = game.Workspace.Terrain
local origin = game.Workspace.TerrainOrigin
local teleport = game.Workspace.TerrainTeleport
terrain:Clear()
terrain:FillBlock(origin.CFrame, Vector3.new(104, 104, 104), Enum.Material.Pavement)
while true do
wait(10)
local parts = terrain:GetTouchingParts()
for index, part in pairs(parts) do
if part.Name == "HumanoidRootPart" then
part.Parent:MoveTo(teleport.Position)
end
end
terrain:Clear()
terrain:FillBlock(origin.CFrame, Vector3.new(104, 104, 104), Enum.Material.Pavement)
end
-
What do you want to achieve? I want to teleport players out of the terrain if they’re inside of it.
-
What is the issue? I cannot call
:GetTouchingParts()
on the terrain to do this. -
What solutions have you tried so far? I tried searching for similar topics about my issue, but could not find anything that could help. I also looked at the Developer Hub, but according to that,
:GetTouchingParts()
is a valid member of terrain.
Additionally, I tried to make a separate part that takes the shape of the terrain, and call :GetTouchingParts()
on that, but the problem with that is that my game makes use of the player’s mouse to destroy terrain, and the part would prevent the player from destroying the terrain.