Part not generating inside the white zone

So basically i wanted to make a part generating inside a zone, but instead some of the parts are spawned outside the zone

Here’s how it looks like:


Code:

while task.wait(.5) do
	if #game.Workspace.Logs:GetChildren() ~= 102 then
	
		local x = game.Workspace.Zone2.Position.X + math.random(-game.Workspace.Zone2.Size.X/2,game.Workspace.Zone2.Size.X/2)
		local z = game.Workspace.Zone2.Position.Z + math.random(-game.Workspace.Zone2.Size.Z/2,game.Workspace.Zone2.Size.Z/2)


		local part = game.ReplicatedStorage.Log
		part.Position = Vector3.new(x,2.1,z)
		local clone = part:Clone()

		clone.Parent = workspace.Logs
	end
end

And also the zone is an union btw

Nvm im dumb i shouldn’t union them

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