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

Clone model and set position ?

I am making a script to drop an item when i click a button gui, i want it to clone a model from lighting and put it under the player but i cant make it work!

this is the part that have a problem

local drop = game.Lighting:FindFirstChild(itemC.Value):FindFirstChild(item.Value):clone()
drop.Parent = game.Workspace.Drops
drop.Position = player.Character.Torso.PositionXYZ

1 answer

You have two problems in this script: First: Models do not have a Position property so you need to use the MoveTo function for this Second: The position you need to move to has to be a new Vector3 so try:

drop:MoveTo(Vector3.new(player.Character.Torso.Position) --XYZ won't work 

You can also use SetPrimaryPartCFrame() to do this too, just make a certain part your PrimaryPart of a model, then use SetPrimaryPartCFrame() to move it. (SurVur pointed this out to me)

2 comments

0

You can also use the SetPrimaryPartCFrame()

0

thanks, but i still have a problem with the first line saying : attempt to index a nil value

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