Help with boxtrap command

Hi! So I need help making an object flip upside down in the replicated storage. It is a Admin Command where you type in ;boxtrap me and it adds a box for where you are but the box isn’t placing.

here’s my explorer

image

here’s my script

            local Target = nil		
			local Box = game.ReplicatedStorage.Box:Clone()
			local Valid = CheckForTarget(Target)

			if Valid then				

				Box.CFrame = Target.Character.HumanoidRootPart.CFrame

				wait(15) 
				Box:Destroy()
			end

Box is a Model object, so you’d actually need to get the PrimaryPart object of it instead

Try this:

Box.PrimaryPart.CFrame = Target.Character.HumanoidRootPart.CFrame

If you don’t have a PrimaryPart I think you can just simply do SetPrimaryPartCFrame instead

Box:SetPrimaryPartCFrame(Target.Character.HumanoidRootPart.CFrame)

Number 2 did not work so i am trying #1

#1 had thhis error


@JackscarIitt

#2 had this error


@JackscarIitt

Click on the box, then go to the properties tab. Tap on “Primary Part” in the properties tab, then tap on one of the parts on the box. That should set the primary part. If you look at the following screen shot, it is right above “behavior” and right below “Parent”.

so then the “Primary Part” for box would be Box2 right
image

Primary Part’s must be part’s, why do u have model’s inside of other models?

Did you parent the model to the workspace?

Box.Parent = workspace

i got the item from the workspace, so i have no clue

let me try
Box.Parent = workspace

For this error, you have to assign a primary part to use :SetPrimaryPartCFrame()

I would suggest using this code:

local Target = nil		
local Box = game.ReplicatedStorage.Box:Clone()
local Valid = CheckForTarget(Target)

if Valid then				

    Box.Parent = workspace
    for _,v in pairs(Box:GetDescendants()) do
        if v:IsA("BasePart") then
            Box.PrimaryPart = v
            break
        end
    end

    Box:SetPrimaryPartCFrame(Target.Character.HumanoidRootPart.CFrame)

    wait(15) 
    Box:Destroy()
end	

so it worked but the box is flipping the wrong way :frowning:

this is what it is supposed to look like

Change this line

To this:

Box:SetPrimaryPartCFrame(Target.Character.HumanoidRootPart.CFrame * CFrame.Angles(0,0,math.rad(180))

now it doesn’t like wait(15)

You forgot a ) at the end of that line.

I missed a parenthesis try this:

Box:SetPrimaryPartCFrame(Target.Character.HumanoidRootPart.CFrame * CFrame.Angles(0,0,math.rad(180)))

I’m glad it works, though could you give the solution to @Rald_s because he wrote most of the code, I just added a little bit to his. Thanks!