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

how to set the position of a block using cframe when cloning using math.random?

Asked by
xxaxxaz 42
3 years ago
Edited 3 years ago

I keep trying to set the position of a block when it is clones but it keeps giving me this error.

Workspace.PaintBall.Action1:13: invalid argument #2 to 'random' (interval is empty)

script:

local clonesneeded = 50 --how many clones are needed of each type

local function ends()
    game.Workspace.PaintBall.Action1.Disabled = true
end

while script.Disabled == false do
    while clonesneeded >= 1 do
        local v1clones = script.ClonesV1:Clone()
        v1clones.Parent = game.Workspace.PaintBall
        v1clones.Name = "clonesV1"
        v1clones.Transparency = 0
        v1clones.Position = Vector3.new(math.random(-70.875, -605.875), 5.473, math.random(-310.375, 260.125)) -- this line has the error

        local v2clones = script.ClonesV2:Clone()
        v2clones.Parent = game.Workspace.PaintBall
        v2clones.Name = "clonesV2"
        v2clones.Transparency = 0
        v2clones.Position = Vector3.new(math.random(-70.875, -605.875), 5.473, math.random(-310.375, 260.125))

        clonesneeded = clonesneeded - 1

    end
end
0
I dont know if it needs a CFrame or not but I do not think it does. xxaxxaz 42 — 3y
0
math.random integers only. v1clones.Position = Vector3.new(math.random(stuff),math.random(stuff),5.473) greatneil80 2647 — 3y
0
thanks! xxaxxaz 42 — 3y
0
I just tested it out and it still has the same error xxaxxaz 42 — 3y

1 answer

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
3 years ago
local clonesneeded = 50 --how many clones are needed of each type

local function ends()
    game.Workspace.PaintBall.Action1.Disabled = true
end

for i = 1, clonesneeded do
    if not script.Disabled then
        local v1clones = script.ClonesV1:Clone()
        v1clones.Parent = game.Workspace.PaintBall
        v1clones.Name = "clonesV1"
        v1clones.Transparency = 0
        v1clones.Position = Vector3.new(math.random(-605.875, -70.875), 5.473, math.random(-310.375, 260.125))

        local v2clones = script.ClonesV2:Clone()
        v2clones.Parent = game.Workspace.PaintBall
        v2clones.Name = "clonesV2"
        v2clones.Transparency = 0
        v2clones.Position = Vector3.new(math.random(-605.875, -70.875), 5.473, math.random(-310.375, 260.125))
    else
        break
    end
end
Ad

Answer this question