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

How do i position the gun shell?

So when i shoot my gun i want a shell to come out this shell spawns at 0,0,0 and it clones to workspace but i want it to drop from the gun to the ground i have already tryed position it heres the code.

This is the function where the shells meant to come out

local y = game.Workspace
local    z = game.ServerStorage["DeagleShell"]
    z:Clone().Parent = y


z.Position = Vector3.new(script.Parent.Barrel)
	
			end












May someone help me fix this please heres a screen shot of where they spawn when i shoot

http://prntscr.com/f15rbl

And then they stack ontop of the second shell

http://prntscr.com/f15saq

May someone Help me thanks!

2 answers

✓ Accepted answer

Hey Prestory,

You cannot create a Vector3 by supplying the barrel. You must supply three numbers as arguments, like so:

Vector3.new(10, 5, 13)

See the documentation page for Vector3 here.

To achieve the effect you want, you should access the barrel's CFrame property, again like so:

z.CFrame = script.Parent.Barrel.CFrame

You may also benefit from reading NoahWillCode's Clean and Tidy as well as this forum post.

Have a nice day!

Best regards, tkcmdr

1 comment

0

Thanks ill try it now

local y = game.Workspace
local    z = game.ServerStorage["DeagleShell"]
    z:Clone().Parent = y


z.CFrame = script.Parent.Barrel.CFrame

            end

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