Search code examples
luaroblox

How do I instantly set an objects X, Y, Z in roblox studio


I would like to know how to set an objects x, y and z co-ordinates. could the solution also involve compatability for

math.random(0, 100)

thanks!


Solution

  • local x = math.random(0,100)
    local y = math.random(0,100)
    local z = math.random(0,100)
    
    -- for debugging, if needed:
    print(x, y, z)
    
    local object = workspace.Part
    object.Position = Vector3.new(x, y, z)