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

How do i position the gun shell?

Asked by
Prestory 1395 Moderation Voter
7 years ago

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

Log in to vote
2
Answered by
tkcmdr 341 Moderation Voter
7 years ago

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

0
Thanks ill try it now Prestory 1395 — 7y
Ad
Log in to vote
0
Answered by
wookey12 174
7 years ago
local y = game.Workspace
local    z = game.ServerStorage["DeagleShell"]
    z:Clone().Parent = y


z.CFrame = script.Parent.Barrel.CFrame

            end

Answer this question