How to Move A Model From A Proximity Prompt

So basically i want it so that if i trigger a prox prom, a model moves to the position of the part that they prox prom is parented to.

this is my script that isnt working lol:

script.Parent.Triggered:Connect(function()
	local peaClone = game.Workspace.Peashooter:Clone()
	local xpos = script.Parent.Parent.Position.X
	local zpos = script.Parent.Parent.Position.Z
	if peaClone.PrimaryPart then
		peaClone:SetPrimaryPartCFrame(Vector3.new(xpos, 3.159, zpos))
	end
end)

Are there any errors in the console?

peaClone should be a descendant of the workspace.

script.Parent.Triggered:Connect(function()
	local peaClone = game.Workspace.Peashooter:Clone()
	local xpos = script.Parent.Parent.Position.X
	local zpos = script.Parent.Parent.Position.Z
	if peaClone.PrimaryPart then
		peaClone.Parent = workspace
		peaClone:SetPrimaryPartCFrame(Vector3.new(xpos, 3.159, zpos))
	end
end)

you’ll need to change the script.Parent.Triggered:Connect(function() to script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild(“Humanoid”) then

That should work

thats if the player touches a part not if they activate the proximity prompt and the script is parented to the proximity prompt

1 Like

no that didnt work
(char limit)

Vector3.new isn’t a CFrame, but this should have given you a written error if it got that far, but since it doesn’t
check to see that the primary part exists by printing in the case it doesn’t.

that still didn’t do anything

(char limit)

I had this exact problem. Instead of doing this, create another part and set it to the primary part, then use weldconstraints, and weld every single part in the model to that part. anchor the root, and unanchor all the other parts, then set primarypartCFrame, it HAS to be the CFrame to the desired position.

Or, use :PivotTo().

What do you mean by this? Could I see an example?

How would I use this?

(Char limit)

here’s a post about it

The thing about :PivotTo() is that you can’t tween it, so if you’re looking to tween, don’t use PivotTo(), use the method above.

I’m not looking to tween it, but would I do

Script.Parent.Triggered:Connect(function(hit)
local peaClone = game.Workspace.PeaShooter:Clone()
local xpos = game.Workspace.TriggerPart.Position.X
local zpos = game.Workspace.TriggerPart.Position.Z
peaClone:PivotTo(xpos, 3.159, zpos)
end)

My bad. SetPrimaryPartCFrame takes a CFrame argument, not a Vector3. Adding onto my previous reply, try this:

script.Parent.Triggered:Connect(function()
	local peaClone = game.Workspace.Peashooter:Clone()
	local xpos = script.Parent.Parent.Position.X
	local zpos = script.Parent.Parent.Position.Z
	if peaClone.PrimaryPart then
		peaClone.Parent = workspace
		peaClone:SetPrimaryPartCFrame(CFrame.new(xpos, 3.159, zpos))
	end
end)

PivotTo is the recommended new way of doing things. I do suggest you look into that. However, SetPrimaryPartCFrame should also work just fine.