Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ##############################################################################################################
- ################### Script Made By TGazza ######################## Model Cloner with overlap check v1.0 ######
- ##############################################################################################################
- ]]
- --// name of your model or part you want to clone
- local Model_Or_Part_Name = "Observation Tower"
- local deBug = false --// change this to true to see a message in the output
- local CloneMETime = 5 --// in seconds!
- --[[
- ##############################################################################################################
- #################### Don't change anything below this unless you know what your are doing!####################
- ##############################################################################################################
- ]]
- local model = (function()
- local Chk = script.Parent:FindFirstChild(Model_Or_Part_Name)
- if(Chk == nil) then
- error("Error: Model_Or_Part_Name Varable is not set\n replace [\" Model_Or_Part_Name \"] With the name of the model or part you want to clone on Line 8 and try again!")
- end
- return Chk
- end)()
- local Cpy = model:Clone()
- local ModelPosition,ModelSize = (function()
- local isModel = model:IsA("Model")
- if(isModel == true) then
- local Bonding_BoxCFrame, Bonding_Box = model:GetBoundingBox()
- return Bonding_BoxCFrame.Position,Bonding_Box
- else
- return model.Position, model.Size
- end
- end)()
- local function isAreaEmpty()
- --// the following code is taken from the roblox wiki
- --// https://developer.roblox.com/en-us/api-reference/function/WorldRoot/FindPartsInRegion3
- --// Just modified to work with models and Parts
- local SA = ModelPosition - (0.5 * (ModelSize*0.95))
- local SB = ModelPosition + (0.5 * (ModelSize*0.95))
- return workspace:IsRegion3Empty(Region3.new(SA, SB))
- end
- local function Cloneit(Model)
- local C = Cpy:Clone()
- C.Parent = workspace
- C:MakeJoints()
- end
- local function DoTheDeed()
- local isClear = isAreaEmpty()
- if(isClear == true) then
- if(deBug == true) then
- print("Quick Spawn point is Clear \n Spawning clone...")
- end
- Cloneit(Cpy)
- else
- if(deBug == true) then
- print("Spawn point is NOT clear waiting for spawn point to become clear...")
- end
- --// Sleep my script! :P
- end
- end
- while true do
- DoTheDeed()
- wait(CloneMETime)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement