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

How to make an object from backpack orbit something in workspace?

Asked by 4 years ago

Okay, so basically, here's my problem: (I'm pretty new to coding.)

I'm trying to make it so when a player pulls out a gun (in this case its an item from a backpack) something else from the backpack orbits around it.

There is a shotty in the game called The Streets and I want soda cans to orbit it whenever you pull the gun out.

I've got the basics laid out (possibly...)

local player = game.Players.LocalPlayer
----
if game.Players.LocalPlayer.Backpack.Shotty == nil then
    if game.Workspace.player.Shotty == true
    then if game.Players.LocalPlayer.Backpack.Drink == true
    then 

I don't know how to finish it, and I'm almost positive I messed up the beginning.

Thanks in advance.

0
what type of objects are Shotty and Drink? theking48989987 2147 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

you think it the wrong way. you think something fly out of backpack. no.

when you equip a gun, a onequip event will be triggered. write the code insider.

the code will be, create an object out of thin air, "Instance.new" and set parent to, and position will be close to the gun...

then, when the gun is equipped(in the same event), you want to know the position of nozzle point of the gun,

third, you learn how to circle an object around the nozzle point. or just use constraints.

then, in the unequip event,

you remove that object circling

Ad

Answer this question