Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with Instances?

Asked by 9 years ago

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

0
RandomNumber.Value ConnorVIII 448 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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])
Ad

Answer this question