workspace:WaitForChild("defaultkid99") repeat script.Parent.Position = script.Parent.Position+Vector3.new(math.random,math.random,math.random) until script.Parent.Position = defaultkid99.Torso.Position
why do i get an error? what does it mean error while parsing expression expected <eof> got =
try using local default = workspace:WaitForChild("defaultkid99")
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
workspace:WaitForChild("defaultkid99")
You didn't define a variable here. This line of code is effectively meaningless.
repeat script.Parent.Position = script.Parent.Position+Vector3.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)
.
until script.Parent.Position = defaultkid99.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.
local defaultkid = workspace:WaitForChild("defaultkid99") repeat local increasevalue = math.random(1,10) -- Change these 2 numbers as you see fit. The resulting variable will be a number equal to or between those two numbers. script.Parent.Position = script.Parent.Position+Vector3.new(increasevalue, increasevalue, increasevalue) wait(1) -- The script would stop working without this wait here 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.