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

How would i put a math.random in here?

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

✓ Accepted answer

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

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