What do you want to achieve? Clone part to a random position but not in all the game only in the RoadModel.Road
What is the issue? idk how to clone it to a random position (in the RoadModel.Road)
This is a video so I want to clone the part on this road only (I can’t upload the video idk why)
What solutions have you tried so far? I saw some topics about that but I didn’t understand
this is my clone script so who can edit it and make the Fire clone to a random position in the bounds of the RoadModel.Road
local Fire = game.ReplicatedStorage.Fire
local Clone = Fire:Clone()
Clone.Parent = workspace
I want to clone a part to a random position inside the RoadModel.Road so not on all the game only on the RoadModel.Road so I want to clone it on RoadModel.Road its hard to explain
Move the part’s CFrame to a random X axis an Z axis near the road.
local RandomRange = math.random(-5,5) -- Generates a random number in between -5 and 5
Part.CFrame = Road.CFrame * CFrame.new(RandomRange,1,RandomRange )
local RandomRange = Random.new():NextNumber(-5, 5) -- Generates a random number in between -5 and 5
Part.CFrame *= CFrame.new(RandomRange, 1, RandomRange)
And the issue you’re having is, if I’m interpreting what you said correctly, you want to spawn something only on the road and not off of it? If that’s the case, the other topic you sent above would work. I’ll attempt to explain it.
local clonedObj = crop1:Clone() --Clones the object
local extents = dirt.Size.X/2 --This is the width of the road divided by two (see image below)
local x = math.random(-extents,extents) --This produces a value that is between the far left and far right sides of the road
clonedObj.Position = dirt.Position + Vector3.new(x,1.8,0) --This places the clonedObj to be directly on the road, but uses the x value to place it anywhere along the width (if that makes sense)
clonedObj.Parent = dirt --Sets the parent
I don’t see why what I posted above doesn’t work, set the Clone’s position using the script above, and that should make it so that the clone doesn’t go off the road
You’re right, sorry: @MONSTERGAMES3609, when you clone the part, set the position like so:
local Fire = game.ReplicatedStorage.Fire
local Clone = Fire:Clone()
local extents = Clone.Size.X/2
local bounds = math.random(-extents, extents)
Clone.Position = Road.Position + Vector3.new(x,Road.Position.Y,0)
Clone.Parent = workspace
local Fire = game.ReplicatedStorage.Fire
local Clone = Fire:Clone()
local boundsX = math.random(-Road.Size.X/2, Road.Size.X/2)
local boundsZ = math.random(-Road.Size.Z/2,Road.Size.Z/2)
Clone.Position = Road.Position + Vector3.new(boundsX,Road.Position.Y,boundsZ)
Clone.Parent = workspace