local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent") --make sure to place the remote there
local obstacletype = {"Checkers","LeftConveyor", "RightConveyor", "Trampolines"}
local seed = game.Workspce.Seed
local seedX = game.Workspace.Seed.X
local seedY = game.Workspace.Seed.Y
local seedZ = game.Workspace.Seed.Z
local incrementX = 0
local incrementY = 0
Remote.OnServerEvent:Connect(function(plr)
	local randomElement = obstacletype[ math.random(#obstacletype) ]
	local model = game:GetService("ServerStorage"):WaitForChild(randomElement):Clone()
	model.Parent = workspace
	model:SetPrimaryPartCFrame(CFrame.new(seedX+incrementX,seedY+incrementY,seedZ)) --sets the CFrame of the model to 0,0,0 relatively to its primary part. Make sure to set the primary part in its properties!!!!
	if incrementX == 128 then
		incrementX = 0
		incrementY += 16
	elseif incrementX == 128 and incrementY == 128 then
		wait(1000000000000)
	elseif incrementX ~= 128 then
		incrementX += 16
	end	
end)

My code (above) is supposed to clone an object and theoretically tile it across a surface. It is not working tho so......... how do I fix it? the models in serverstorage are models and this script is just a script (not local)

4 comments

0

I don't know why the spacing is kinda weird...

0

use a code block

0

there is a blue button that says lua

1

Try adding a 1 in [ math.random(1, #obstacletype) ] so the script picks only one.