Nothing can truely express my confusion

luau is being stubborn. I’m trying to make a clone of the world and stuff it in a worldmodel (like 3 parts, no point in optimization atp)
I specifically coded it so ONLY if it is a basepart or model, it will be cloned. Luau decided not to. It tried cloning Terrain, which they just don’t let you. It stops my entire script.

image
this is the code at the very start.

image
this is the error said code gives me.

I try to counteract this with

an impenetrable wall, or so i thought…
roblox hits me with

“…what?”
“HOW???”, I thought to myself…
“i literally EXCLUDED the terrain class… maybe i’ll just have to use a different method… maybe using part:IsA("Terrain") == false…?”

i try again.

image

mods ban terrain they’re literally hacking


i’ve tried just deleting terrain. Doesn’t work.


one restart later. it’s teabagging on my dead body atp

im done for the night. I’ll check the replies when i’m out of school in about 13 hours. Goodnight, roblox forums.

I’m pretty sure terrain is inheriting from base part so that might cause this when doing IsA(“BasePart”)

What I would do is just add a statement that checks for the name and block Terrain

and part.Name ~= “Terrain” …

1 Like

If it still acts odd I guess you can always pcall it.

I remember this happening to me with models and primary parts. I would specifically exclude the Primary part of the model yet it always included it, so I resorted to excluding the part called “Primary”. Just wanted to share this error that is very similar to this one.

Oh and btw, make sure to do this

if (part:IsA(“BasePart”) or part:IsA(“Model”)) and part.Name ~= “Terrain” then

The problem is that a terrain is considered a BasePart and it’s not getting to the name ~= terrain statement because it’s added after the or statement

Terrain is technically considered a BasePart, it’s not just Terrain itself. If you didn’t know, some instances have some kind of subclasses, like how PointLight, SpotLight, and SurfaceLight returns true if you run :IsA("Light"), or how Tool and Actor returns true if you run :IsA("Model").

Now that you know about the subclasses, lets get to the main problem. The problem is how the condition is ordered.

Because Terrain is a BasePart, part:IsA("BasePart") would return true, and in the script you’re checking if parts considered a Model doesn’t have the ClassName equal to Terrain, which will always return true because no instance considered a Model would be Terrain.

So the solution would be to close part:IsA("BasePart") and part:IsA("Model") in a parenthesis.

There you have it, a solution + new information. Happy scripting!

1 Like

You could use:

for _, obj in workspace:GetChildren() do
	if obj:IsA("Terrain") then
		continue
	end

	if not (obj:IsA("BasePart") or obj:IsA("Model")) then
		continue
	end
	
	local clone = obj:Clone()
end

Use folders to organize your workspace, problem solved

You gotta do

if part.ClassName~="Terrain" and (part:IsA("Model") or part:IsA("BasePart")) then

if I’m not mistaken

1 Like

This code is not working because the and takes precedence. It’s actually calculating part:IsA("Model") and part.ClassName ~= "Terrain" together. Then it does the or with part:IsA("BasePart"). Since Terrain is a BasePart, it will be true for Terrain. You can fix this by using parenthesis or guard clauses to properly separate the conditions.

if part:IsA("Terrain") then continue end

if part:IsA("BasePart") or part:IsA("Model") then
    local clone = part:Clone()
    if not clone then continue end
    clone.Parent = p1.SurfaceGui.ViewportFrame.WorldModel
end

Keep in mind that if the part has Archivable set to false, it will not be cloned and :Clone() will return nil.

1 Like

Terrain’s name is Terrain. Terrain is actually one “part”. You just need to not pick that one single special object that is named Terrain..

local set = game:GetService("ReplicatedStorage"):WaitForChild("Set") --wherever
for _, obj in workspace:GetChildren() do
	if obj.Name ~= "Terrain" and not obj:FindFirstChild("Humanoid") then
		local clone = obj:Clone() clone.Parent = set
	end
end

Also blocks trying to clone a player.

idk check streaming enabled that usually solves all my terrain problems

Are you still having problems with this? .. I know for a fact my script there works fine.

yeah, this was solved by just putting the things i wanna render in the portals in a seperate folder in Replicated Storage

i just didn’t check the forums after around a day of posting it, sorry!

Just a way of calling that with that name, as it is a special object as a whole itself.