How to clone random models?

I want to clone random parts

i made a script and there is no error output

local light = game.Lighting.kucukler
local kucuk = {light.a,light.b,light.d,light.e,light.c,light.f,light.g,light.aa,light.ab,light.ac,light.ad}
for _, sled in pairs(workspace:GetChildren()) do
	if sled.Name == "sled" then
		local regen = sled.Regen
		local ClickDetector = regen.Click
		ClickDetector.MouseClick:Connect(function()
			local a = sled:FindFirstChild("kizak")
			local kucukklon = kucuk[math.random(#kucuk)]
				if sled:FindFirstChild("kizak") then
					regen.alarm:Play()
				return end
			local value = sled:WaitForChild("Value")
			if value.Value == kucuk then
				local new = kucukklon:clone()
				new.Parent = sled
				new.Name = "kizak"
				new:MakeJoints()
				regen.BrickColor = BrickColor.random()
				new:FindFirstChild("Seat").Position = regen.Position
				wait(5)
				regen.BrickColor = BrickColor.random()
			end
		end)
	end
end
1 Like

This does not need to be in a loop. This will run when clicked. Should not be inside any code. Thats the first thing. Also is this in a local script?

1 Like

this script isnt a loop, this script detects the part that which part did played clicked between other “same named” parts. And this script isnt a local script but its in the serverscriptservice.

The code should work, try printing if its in the workspace and print its position to see if it returns nil

the code worked after i deleted the “if value.Value == kucuk then”

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.