Ok, there's a lot of things wrong with your script, so I'll go through them one by one and then give you a script that works
1 | workspace:WaitForChild( "defaultkid99" ) |
You didn't define a variable here. This line of code is effectively meaningless.
2 | script.Parent.Position = script.Parent.Position+Vector 3. new(math.random,math.random,math.random) |
math.random
requires parameters - those being a smaller number and a greater number, and it'll pick a number between those two numbers. Proper usage would be something along the lines of math.random(1,10)
.
1 | until script.Parent.Position = defaultkid 99. Torso.Position |
When comparing two values, you have to use two equals signs to signify 'is this thing equal to that other thing'. If you use one equal sign, you're telling the script to set the first value to the second, which wouldn't work in this case. This is also the reason for your error message. Not to mention you use defaultkid99
here as if you defined a variable, which you didn't.
So all together, here's a fixed up script for you.
1 | local defaultkid = workspace:WaitForChild( "defaultkid99" ) |
3 | local increasevalue = math.random( 1 , 10 ) |
4 | script.Parent.Position = script.Parent.Position+Vector 3. new(increasevalue, increasevalue, increasevalue) |
6 | until script.Parent.Position = = defaultkid.Torso.Position |
Now this would work on paper, but here's some notes. Whatever script.Parent
is will be moving along all 3 axis - X,Y,Z positively. That means it'll always be moving forward a little, left a little, and up a little. If this is not your intention, you can play around with this line: script.Parent.Position = script.Parent.Position+Vector3.new(increasevalue, increasevalue, increasevalue)
by changing one or two of the three increasevalue
variables to 0 until it moves in a way you see fit.