Hi there. I’m trying to make a part that can be stepped on to be able to get models into the workspace by cloning them from replicated storage into the workspace once a player steps on said part. Problem is that I run into an issue regarding my code for it.
The part to be stepped on looks something like this (as reference of location):
Once a player steps on said part, it will generate a new part or “area”.
This is the code that is being used in the part to clone the models from replicated storage:
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local radnumb = math.random(1,2)
if radnumb == 1 then
radnumb = "Grasslands"
local repstore = game:GetService("ReplicatedStorage")
local part = repstore:GetChildren()
if part.Name == radnumb then
part:Clone()
local primaryp = script.Parent.Parent.PrimaryPart
part.Parent = game.Workspace
part:SetPrimaryPartCFrame(primaryp.CFrame)
part:MoveTo(primaryp.Position + Vector3.new(0, 0, 30))
print("Script will now be destroyed.")
script:Destroy()
else
warn(radnumb.." did not load. Replication Failure!")
end
elseif radnumb == 2 then
radnumb = "Snow Biome"
local repstore = game:GetService("ReplicatedStorage")
local part = repstore:GetChildren()
if part.Name == radnumb then
part:Clone()
local primaryp = script.Parent.Parent.PrimaryPart
part.Parent = game.Workspace
part:SetPrimaryPartCFrame(primaryp.CFrame)
part:MoveTo(primaryp.Position + Vector3.new(0, 0, 30))
print("Script will now be destroyed.")
script:Destroy()
else
warn(radnumb.." did not load. Replication Failure!")
end
end
end
end)

For whatever reason, I’m not shown any errors whatsoever regarding the code but it seems to not work for some distinct lines, supposedly around in these areas:
![]()
Don’t really know how to approach how to fix this so any help would be appreciated! (I’ve listed this issue on the devforum before but I unintentionally didn’t clarify that this is in fact NOT terrain generation. This is actual model cloning)
