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

Using random, how would I make a part change its x,z move randomly within 10 studs?

Asked by
NecoBoss 194
10 years ago

So I'm not sure how to use random. Please explain how I would let the y stay the same but the x and z change by a random amount but within a range.

1 answer

Log in to vote
3
Answered by
Sublimus 992 Moderation Voter
10 years ago

Use math.random() in only the x and y positions of the Vector3.

part = game.Workspace.PARTLOCATION
game.Workspace.Part.Position = Vector3.new(part.Position.X + math.random(-10,10), part.Position.Y, part.Position.Z + math.random(-10,10))
0
Hey thanks. You've been really helpfull today! NecoBoss 194 — 10y
0
No problem! Sublimus 992 — 10y
Ad

Answer this question