Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with Instances?

On line 10-19 it uses a table change surfaces to smooth but doesn't change surfaces, why?

I have another question why do the parts always spread in a horizontal way?

I want them to spread every way kinda like a shotgun.

How would I fix these problems?

Player = game.Players.LocalPlayer
Character = game.Players.LocalPlayer.Character
Tool = script.Parent
----------------------------
function CreatePart(CFPosition)
local Part = Instance.new("Part",game.Workspace)
Part.FormFactor = "Custom"
Part.Size = Vector3.new(1,0.2,1)
Part.CFrame = CFPosition
local Surfaces ={
	Part.BackSurface,
	Part.BottomSurface,
	Part.FrontSurface,
	Part.LeftSurface,
	Part.RightSurface,
	Part.TopSurface}
for i,v in pairs (Surfaces)do
	print(v)
	v = "Smooth"
	end
	return Part
end
----------------------------
Tool.Equipped:connect(function(Mouse)
	Mouse.Button1Down:connect(function()
		for Index = 1,5 do
			local PartPosition = CFrame.new(Mouse.Hit.p)*CFrame.new(0,1,0)
			local RandomNumber = math.random(1,5)
			local RandomizedPosition = PartPosition*CFrame.new(RandomNumber,RandomNumber,RandomNumber)
			Parts = CreatePart(RandomizedPosition)
			Parts.Name = "Part"..Index
			
		end
		
	end)
end)

P.s I got no errors in the output

1 comment

0

RandomNumber.Value

1 answer

✓ Accepted answer

I would think it's because you use the same random number for all 3 components of the CFrame :

local RandomNumber = math.random(1,5) -- <-----
local RandomizedPosition = PartPosition*CFrame.new(RandomNumber,RandomNumber,RandomNumber)

Maybe :

local RandomNumbers = {
	math.random(1,5),
	math.random(1,5),
	math.random(1,5)
}
            local RandomizedPosition = PartPosition*CFrame.new(RandomNumbers[1],RandomNumbers[2],RandomNumbers[3])

This discussion is preserved as it was. New answers, comments, and votes are closed.