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

How would i put a math.random in here?

Asked by 10 years ago

How and where would i put a math.random script in here because i want it to go in random locations when i touch it.

function onTouched(hit)

    script.Parent.Position=Vector3.new(0,0,0)
script.Parent.Anchored=true


end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

You would put it in any of the elements of the new Vector3 value.

function onTouched(hit)
    script.Parent.Position = Vector3.new(math.random(-10,10),math.random(1,5),math.random(-20,20))
    script.Parent.Anchored = true
end

script.Parent.Touched:connect(onTouched)

The part will re-position itself in:

x-axis: Between -10 and 10

y-axis: Between 1 and 5

z-axis: Between -20 and 20

Ad

Answer this question