Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Weird issue with Cloning and CFraming?

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

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.

4 comments

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

0

I'm sorry, I am not getting enough details to accurately answer your question. Show me the hierarchy?

0

Brick > Script.

0

Heres what I mean http://prntscr.com/7y36ah

This discussion is preserved as it was. New answers, comments, and votes are closed.