math.random(MinimumValue, MaximumValue)
Here is an example:
x = math.random(1, 10)
print(x)
The above code will randomly choose a number between 1 - 10 (integer) and print it, if you don't put anything between the parenthesis it will choose a random number between 0 - 1 (will be pointless if you want to teleport randomly).
Like 18cwatford said, CFrame takes 3 arguments that are seperated by commas CFrame(x, y, z), the way you are trying to use it is wrong, correct way: part.CFrame = CFrame.new(x, y, z)
So if we want to teleport to random locations we would use: part.CFrame = CFrame.new(math.random(minX, maxX), math.random(minY, maxY), math.random(minZ, maxZ))
Use this syntax to select a random brick color:
part.BrickColor = BrickColor.new(math.random(1,255)/255, math.random(1,255)/255, math.random(1,255)/255)
The first argument in the BrickColor is red, the second is green and third is blue.
So this is how your code is suppose to look like:
function onTouch(part)
local t = part.Parent:findFirstChild("Torso")
if t ~= nil then
t.BrickColor = BrickColor.new(math.random(1,255)/255, math.random(1,255)/255, math.random(1, 255)/255)
t.CFrame = CFrame.new(math.random(minX, maxX), math.random(minY, maxY), math.random(minZ, maxZ))
end
end
script.Parent.Touched:connect(onTouch)