Why does this cloned part spawn in the same place when it is in workspace

local part = game.ReplicatedStorage:WaitForChild("ClonedPart")
local Buffer = 5



while wait(Buffer) do
	local partClone = part:Clone()
	partClone.Parent = workspace
	
	part.CFrame = CFrame.new( math.random(-140,-80),0, math.random(-10, 50))
end

This code spawns a part in the same position every 5 seconds I want to give it a random position in this square
image

Hi! How about trying the following:

local part = game.ReplicatedStorage:WaitForChild("ClonedPart")
local Buffer = 5



while wait(Buffer) do
	local partClone = part:Clone()
	partClone.Parent = workspace
	
	part.CFrame.Position = Vector3.new(x, y, z)
end

This script just does the same thing

I apologize, you were right! I think this should work:

local part = game.ReplicatedStorage:WaitForChild("ClonedPart")
local Buffer = 5



while wait(Buffer) do
	local partClone = part:Clone()
	partClone.Parent = workspace

	local randomPosition = Vector3.new(math.random(-140,-80), 0, math.random(-10, 50))
	print("Random Position:", randomPosition)

	-- Apply random position to the cloned part
	partClone.CFrame = CFrame.new(randomPosition)
end

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