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

How do I input the Vector3 position here?

Asked by
traigla 75
9 years ago

I get no error messages to the output, but when I run the game, the only thing in the BodyPosition position is 0,0,0 and when I try to manually change it, it returns to 0,0,0, and help?

Here is the code:

targets = game.Workspace.Path:GetChildren()

Main = script.Parent.Main
function run()
    for i,v in pairs(targets) do
        if Main.Position ~= v.Position then
            local position = v.Position
            Main.BodyPosition.position = Vector3.new(position)
        end
        wait()
    end
    run()
end

run()
0
Make sure force is strong enough to move the part, and the part is unanchored. M39a9am3R 3210 — 9y
0
Sorry? traigla 75 — 9y
1
Line 8: Try replace Vector3.new() with v.Position, Provide any output errors (if any) please? fahmisack123 385 — 9y
0
It works, thank you for the help. traigla 75 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

When you set the variable 'position' it is already a Vector3 value, not just 3 numbers. Line 8 is the same as:

Main.BodyPosition.position = Vector3.new(Vector3.new(0,0,0))

All you need to do is replace the Vector3.new(position) with position so your code will look like this:

targets = game.Workspace.Path:GetChildren()
Main = script.Parent.Main

function run()
    for i,v in pairs(targets) do
        if Main.Position ~= v.Position then
            local position = v.Position
            Main.BodyPosition.position = position
        end
        wait()
    end
    run()
end

run()
Ad
Log in to vote
0
Answered by 9 years ago

Actually I think the problem is that "position" doesn't exists, because it's with the "P" uppercase, so:

Main.BodyPosition.Position = position

Answer this question