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

Drop things from inventory, but not at the wanted position?

Asked by
Paldi 109
7 years ago

Hello, i made an inventory gui and a button to drop items (wich are group models) for that everything is fine the only thing is that i want the item to drop in front of the player but i can only make it drop like 2 blocks away from the player but always on the same side wherever my character is facing, it will be say, -2 blocks away on the x axis of the workspace.

thats the line used to do it

drop:SetPrimaryPartCFrame(CFrame.new(player.Character.Torso.Position.x -2, player.Character.Torso.Position.y -2.7, player.Character.Torso.Position.z ))

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
hcf = MainPart.CFrame
fp = hcf.p + hcf:vectorToWorldSpace(Vector3.new(0,0.4,-1.1))
scf = CFrame.new(fp,YeniEk.Position)
ilkKutuk.CFrame = scf + (scf.lookVector * ((ilkKutuk.Size.Z/2)-1))

So, this is from my old library which I used to generate random trees. This was handling my trees' positioning and rotating needs. But to be honest I forgot what does what actually. I think scf is position, multiplying scf's lookVector with size of ilkKutuk gives us the correct position. So, I suggest you to do something like this:

drop:SetPrimaryPartCFrame(player.Character.Torso.Position + (player.Character.Torso.CFrame.lookVector * -2))

Not sure if it will work or not.

0
with this line i get this error: Players.Player1.PlayerGui.UI.Inventory.Menu.LocalScript:26: bad argument #2 to '?' (Vector3 expected, got CFrame) Paldi 109 — 7y
0
Edited it(Just deleted CFrame.new) superalp1111 662 — 7y
0
now i get: Unable to cast Vector3 to CoordinateFrame Paldi 109 — 7y
Ad

Answer this question