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

How can I select a random position inbetween two parts?

Asked by 5 years ago

On line 12, my code isn't working. How can I make it so it picks a random position in between the start and end parts? (Part name "Start" and part named "End"

This is my error: Workspace.DrizzleRainCloud.RainGenerator:12: bad argument #2 (interval is empty)

01currentDroplet = 0
02 
03 
04while true do
05    --Creates the droplet
06    droplet = Instance.new("Part")
07    --print("Instanced a the droplet")
08    --Sets the droplet's properties
09    droplet.BrickColor = BrickColor.new("Toothpaste") or BrickColor.new("Teal")
10    local start = game.Workspace.Start
11    local xend = game.Workspace.End
12    droplet.Position = Vector3.new(math.random(start.Position.X, xend.Position.X)(math.random(start.Position.Y, xend.Position.Y)(math.random(start.Position.Z, xend.Position.Z))))
13    droplet.Anchored = true
14    droplet.Size = Vector3.new(1, 2, 1)
15    droplet.Transparency = 0.8
View all 38 lines...
0
You forgot commas. Vector3.new(math.random(start.Position.X, xend.Position.X), math.random(start.Position.Y, xend.Position.Y), math.random(start.Position.Z, xend.Position.Z)) mixgingengerina10 223 — 5y
0
I tried that, although I got this error: Workspace.DrizzleRainCloud.RainGenerator:12: Expected ')' (to close '(' at column 81), got ',' soccerstardance251 29 — 5y
0
I updated my comment mixgingengerina10 223 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

bro your thinking this too hard

1local pos = start.Position:Lerp(xend.Position, math.random(1, 100) / 100)
2droplet.Position = pos

All you gotta do is get a random percentage of a lerp and place it there. simple

0
It works thanks! soccerstardance251 29 — 5y
Ad

Answer this question