Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I position a part every 5 seconds?

Asked by
Dwayder 29
7 years ago

I'm trying to make a part go back to its original position every 5 seconds. I've tried this:

01local positionyo = -53, 5.15, 177
02while true do
03    wait(5)
04    if script.Parent.Position == positionyo then
05        break
06    end
07    if script.Parent.Position ~= positionyo then
08        script.Parent.Position = positionyo
09    end
10end

The script its supposed to check if the part its first in that position so it won't run the function for nothing. I'm not too much of a scripter at all but I have a feeling I'm doing this very wrong.

0
In this case, 'positionyo' value will be the first value stated in the line which is the '-53' User#17685 0 — 7y
0
try using Vector3.new(positionyo) Instead of posotion yo. Nikkulaos 229 — 7y

1 answer

Log in to vote
2
Answered by
Nikkulaos 229 Moderation Voter
7 years ago

You would need to use Vector3 in your script. Sadly roblox cant position things with just Position = 0,0,0, you need to use Position = Vector3.new(0,0,0).

Your new script should look something like this:

01local positionyo = Vector3.new(-53, 5.15, 177)--Changed it to Vector 3
02while true do
03    wait(5)
04    if script.Parent.Position == positionyo then
05        break
06    end
07    if script.Parent.Position ~= positionyo then
08        script.Parent.Position = positionyo
09    end
10end

Hope this helps!

Ad

Answer this question