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

Issues with :MoveTo(Vector3.new(math.random(), math.random(), math.random()))?

This script doesn't randomly move the model in a given area It clones a model from ReplicatedStorage and moves the model workspace and is then randomly placed in a given area.

Any fix?

(there isn't any error output either)

code looks a little less organized here but heres an image

local shelfcloud = game.ReplicatedStorage.Clouds.Low_Level_Clouds["Shelf Cloud"]
local cumulus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Cumulus
local stratus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratus
local stratocumulus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratocumulus
wait(0.8)

while true do
	local cloud = math.random(2000)
	if cloud < 800 then
		game.ReplicatedStorage.Clouds.Low_Level_Clouds.Cumulus:Clone().Parent = workspace
		game.ReplicatedStorage.Clouds.Low_Level_Clouds.Cumulus:MoveTo(Vector3.new(math.random(-10239.5,14335.5),math.random(1655.5,2283.5),math.random(-14335.5,10239.5)))
	end
	if cloud < 900 then
		game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratus:Clone().Parent = workspace
		game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratus:MoveTo(Vector3.new(math.random(-10239.5,14335.5),math.random(1655.5,2283.5),math.random(-14335.5,10239.5)))
	end
	if cloud < 1200 then
		game.ReplicatedStorage.Clouds.Low_Level_Clouds.Nimbostratus:Clone().Parent = workspace
		game.ReplicatedStorage.Clouds.Low_Level_Clouds.Nimbostratus:MoveTo(Vector3.new(math.random(-10239.5,14335.5),math.random(1655.5,2283.5),math.random(-14335.5,10239.5)))
	end
	wait(math.random(0.8,16))
end

2 comments

0

Learn to use variables.

0

I'm still new at learning variables, so saying that to me isn't helping.

2 answers

✓ Accepted answer

You're cloning the clouds and then you move the originals.

Try this (if I misspelled something, you'll have to excuse me)

local shelfcloud = game.ReplicatedStorage.Clouds.Low_Level_Clouds["Shelf Cloud"]
local cumulus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Cumulus
local stratus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratus
local stratocumulus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratocumulus
local nimbostratus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Nimbostratus
wait(0.8)

while true do
    local cloud = math.random(2000)
    if cloud < 800 then
        cumulusClone = cumulus:Clone()
		cumulusClone.Parent = workspace
		cumulusClone:MoveTo(Vector3.new(math.random(-10239.5,14335.5),math.random(1655.5,2283.5),math.random(-14335.5,10239.5)))
    end
    if cloud < 900 then
		stratusClone = stratus:Clone()
       	stratusClone.Parent = workspace
		stratusClone:MoveTo(Vector3.new(math.random(-10239.5,14335.5),math.random(1655.5,2283.5),math.random(-14335.5,10239.5)))
    end
    if cloud < 1200 then
        nimbostratusClone = nimbostratus:Clone()
       	nimbostratusClone.Parent = workspace
		nimbostratusClone:MoveTo(Vector3.new(math.random(-10239.5,14335.5),math.random(1655.5,2283.5),math.random(-14335.5,10239.5)))
    end
    wait(math.random(0.8,16))
end

1 comment

0

Works very well, ty.

I believe that this would work:

local shelfcloud = game.ReplicatedStorage.Clouds.Low_Level_Clouds["Shelf Cloud"]
local cumulus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Cumulus
local stratus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratus
local stratocumulus = game.ReplicatedStorage.Clouds.Low_Level_Clouds.Stratocumulus
wait(0.8)
 
while true do
    local cloud = math.random(2000)
	local xPosition = math.random(-10239.5,14335.5)
	local yPosition = math.random(1655.5,2283.5)
	local zPosition = math.random(-14335.5,10239.5)
    if cloud <= 800 then
        local clonedCloud = cumulus:Clone()
		clonedCloud.Parent = workspace
		clonedCloud.Position = Vector3.new(xPosition,yPosition,zPosition)
    end
    if cloud <= 900 then
        local clonedCloud = stratus:Clone()
		clonedCloud.Parent = workspace
		clonedCloud.Position = Vector3.new(xPosition,yPosition,zPosition)
    end
    if cloud <= 1200 then
        local clonedCloud = stratocumulus:Clone()
		clonedCloud.Parent = workspace
		clonedCloud.Position = Vector3.new(xPosition,yPosition,zPosition)
    end
    wait(math.random(0.8,16))
end

Hope this helps. If it did, great! Accepting the answer would be even greater! :P

4 comments

0

I think both of our answers would work, just note that in the original code if "cloud" was greater than 1200 it would clone the "Nimbostratus" cloud, not the "Stratocumulus" one.

0

Meaning that this "<= 1200" should be ">= 1200". Am I right?

0

-1 for not explaining.

0

Doesn't work.

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