Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I input the Vector3 position here?

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()

4 comments

0

Make sure force is strong enough to move the part, and the part is unanchored.

0

Sorry?

1

Line 8: Try replace Vector3.new() with v.Position, Provide any output errors (if any) please?

0

It works, thank you for the help.

2 answers

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()

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

Main.BodyPosition.Position = position

This discussion is preserved as it was. New answers, comments, and votes are closed.