Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I stop a cloned part from being positioned on top of a part?

Asked by 6 years ago
Edited 6 years ago

So, when I clone a part, I want to position it inside of a part. Instead, it positions it on top of the part that's supposed to be positioned to.

Here's my script:

local tool = script.Parent.Parent
local player = game.Players.LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local animation = game.ServerStorage.Anime
local blackthings = game.ServerStorage.Model.Part

local db = false
tool.Equipped:connect(function(a)
    for _,v in pairs(tool:GetChildren()) do
        v.Transparency = 1
    end
    a.Button1Down:connect(function()
        if not db then
            db = true

            animation.AnimationId = "http://www.roblox.com/asset/?id=1575109264"
            local animTrack = hum:LoadAnimation(animation)
            animTrack:Play()
            for _,v in pairs(tool:GetChildren()) do
                v.Transparency = 0
                a = 0
                repeat
                local blackthingsClone = blackthings:Clone()
                blackthingsClone.Parent = v
                blackthingsClone.CFrame = CFrame.new(v.CFrame)
                a = a + 1
                print(a)
                until a == 10
                wait()
            end
            wait(5)
            db = false
        end
    end)
end)
0
It's just physics, the cloned part(or the generated one) can't be with "can collide" to don't let this happen! Leamir 3138 — 6y
0
the thing is, cancollide is turned off. also, it teleports into the ground GIassWindows 141 — 6y
0
You could use CFrame instead. It pretty much ignores parts, unlike Vector3. User#20279 0 — 6y
0
How could I use CFrame? Can you explain for me please? GIassWindows 141 — 6y
0
Give me a second to make an answer. User#20279 0 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

So Vector3 is like positioning a part but with collisions, CFrame for me is the same thing but with no collisions.

On line 23, you’re changing the position, but you want it to go in a part. This is what you would do using CFrame :

blackthingsClone.CFrame = CFrame.new(v.CFrame)

Think of .CFrame as .Position, and replace Vector3.new with CFrame.new. The part should go in the other part with no problems.

0
it says "00:53:37.843 - Players.GIassWindows.Backpack.Tool.Handle.LocalScript:25: bad argument #1 to 'new' (Vector3 expected, got CFrame)" GIassWindows 141 — 6y
0
Did you put line 23 exactly like the one I said? No .Position or Vector3 anywhere? User#20279 0 — 6y
0
no .Position or Vector3. I replaced it with CFrame GIassWindows 141 — 6y
0
Can you edit your question with the script you have now then? I need to see what’s wrong. :I User#20279 0 — 6y
View all comments (7 more)
0
Edited GIassWindows 141 — 6y
0
It should work. Actually, can you put the “blackthings” in ReplicatedStorage and change line 5? Localscripts can’t access ServerStorage. User#20279 0 — 6y
0
Oh, and try changing the v.CFrame back into v.Position. The error says it’s expecting a Vector3 value instead? Sorry for making this complicated. User#20279 0 — 6y
0
Hey! It worked! Thank you so much for helping me, this has been a problem for me for ages! GIassWindows 141 — 6y
0
Also, how would I do that with a model? GIassWindows 141 — 6y
0
:SetPrimaryPartCFrame() if you want to move a whole model using CFrame. Also make sure to set a PrimaryPart. It’s a property in the model. User#20279 0 — 6y
0
Thanks dude! GIassWindows 141 — 6y
Ad
Log in to vote
0
Answered by
zblox164 531 Moderation Voter
6 years ago
Edited 6 years ago

I would try anchoring the part like this:

local part = Part:Clone().Parent = -- Location

part.Anchored = true

You could also try turning CanCollide off:

part.CanCollide = false
0
i want it to clone into it then fall out. but it spawns about 3 - 5 studs above it. GIassWindows 141 — 6y
0
I also turned cancollide off GIassWindows 141 — 6y
0
Then just re position the part after it clones. Use the wait function to to this. zblox164 531 — 6y

Answer this question