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

(Solved) How do I make a part's position the same as another?

I want to make a TextButton that creates a part and sets the position to where the player is, if anything, slightly in front of it.

Here is the code I have so far:

function onclick()
	
	local player = game.Players.LocalPlayer
	local character = player.Character
	local mouse = player:GetMouse()
	local p = Instance.new("Part")
	
	local pos = character.LowerTorso.Position
	p.Parent = game.Workspace
	p.Position = Vector3.new(pos)


end

script.Parent.MouseButton1Click:Connect(onclick)

The script is a local script by the way. Any help would be appreciated! :)

EDIT: Oops! I'm an idiot lol! I was putting the Vector3 in "p.Position = Vector3.new(pos)". The solution is to have just "p.Position = pos". Sorry about that!

2 answers

✓ Accepted answer

Oops! I'm an idiot lol! I was putting the Vector3 in "p.Position = Vector3.new(pos)". The solution is to have just "p.Position = pos". Sorry about that!

You can also use CFrame:

function onclick()
	 
	local player = game.Players.LocalPlayer
	local character = player.Character
	local mouse = player:GetMouse()
	local p = Instance.new("Part")
	
	local pos = character.LowerTorso.Position
	p.Parent = game.Workspace
	p.CFrame = CFrame.new(pos)
end
 
script.Parent.MouseButton1Click:Connect(onclick)

Hope this helped!

2 comments

0

Thanks for the tip! :D

0

No problem! :D

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