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

Clone model and set position ?

Asked by
Paldi 109
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)

0
You can also use the SetPrimaryPartCFrame() SurVur 86 — 9y
0
thanks, but i still have a problem with the first line saying : attempt to index a nil value Paldi 109 — 9y
Ad

Answer this question