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

Weird issue with Cloning and CFraming?

Asked by
drew1017 330 Moderation Voter
9 years ago

So, I have a brick with a script in it, we'll refer to it as Brick1. The script:

Comic explaining what i mean due request http://prntscr.com/7y36ah

--Stuff about determining what spawnedLoot is which is irrelevant

    local spawnedLoot = game.ReplicatedStorage.Loot[choice]:Clone()
spawnedLoot.Parent = workspace
spawnedLoot:SetPrimaryPartCFrame(script.Parent.CFrame) <---------------
script:Destroy()

Which works as expected, when I start the game spawnedLoot spawns as expected.

Now for my game i'm going to need to clone this brick, so I copied it to ReplicatedStorage and in-game, used another script to make a clone of it (the one in repstorage). We'll refer to this as Brick2.

Brick2's script DOES work perfectly, with one thing... instead of it's spawnedLoot's position being at Brick2, it's at Brick1. I have NO idea how this could possibly happen, so could someone with more experience with cloning help me out here?

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
9 years ago

From the looks of it, you already know what the problem is:

spawnedLoot:SetPrimaryPartCFrame(script.Parent.CFrame)

More specifically;

script.Parent.CFrame

The issue is you are setting the position of Brick2 to the position of the parent of the script.

0
Um yes, but this is a NEW brick being cloned. That means that the new brick's script should go to IT'S script.Parent.CFrame, which it is not drew1017 330 — 9y
0
I'm sorry, I am not getting enough details to accurately answer your question. Show me the hierarchy? Validark 1580 — 9y
0
Brick > Script. drew1017 330 — 9y
0
Heres what I mean http://prntscr.com/7y36ah drew1017 330 — 9y
Ad

Answer this question