Script not assigning part random size

I have code that clones a part and gives it a random size but it wont give it a random size it makes the size 0.001 on all XYZ

code:

local db = false

script.Parent.Touched:Connect(function(hit)
	if hit.Velocity.Y >= 20 or hit.Velocity.Y >= -20 and hit.Parent:FindFirstChild("Humanoid") and db == false then
		db = true
		
		local cln = workspace.Stone:Clone()
		cln.Parent = workspace
		cln.Anchored = false
		cln.Position = cln.Position + Vector3.new(math.random(-3,3),math.random(1,3),math.random(-3,3))
		cln.Shape = Enum.PartType.Block
		cln.Size = Vector3.new(math.random(.2,.4),math.random(.2,.4),math.random(.2,.4))
		
		script.Parent.SFX:Play()
		
		wait(.2)
		
		db = false
		
	end
end)

I am having a problem with the line

	cln.Size = Vector3.new(math.random(.2,.4),math.random(.2,.4),math.random(.2,.4))

There is no errors in the output either

1 Like

The math.random is likely rounding up to 1 which is why it is not random but just 1, 1, 1

No the size is
image
when it tries to do random size

local function decimalRandom(minimum, maximum)
    return math.random()*(maximum-minimum) + minimum
end

print(decimalRandom(0.2, 0.4))

try this.

2 Likes

It worked thank you for helping me

1 Like

Great! no worries

please mark it as a solution :smile:

1 Like

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