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