local MakeShell = coroutine.wrap(function(Gun)
local Bolt = Gun.Bolt
local Bullet = game.ReplicatedStorage.Objects.Shell:Clone()
Bullet.Parent = game.Workspace
Bullet.CFrame = (Bolt.CFrame * CFrame.Angles(0, math.rad(90), 0)) + Vector3.new(.05,0,0)
Bullet.Anchored = false
Bullet.Velocity = Vector3.new(0,30,10)
game.Debris:AddItem(Bullet, 3)
end)
--Function call
MakeShell(Gun)
Any tips?
2 Likes
You don’t even need coroutines
in this case, just make a simple function instead:
local function MakeShell(Gun)
local Bolt = Gun.Bolt
local Bullet = game.ReplicatedStorage.Objects.Shell:Clone()
Bullet.Parent = game.Workspace
Bullet.CFrame = (Bolt.CFrame * CFrame.Angles(0, math.rad(90), 0)) + Vector3.new(.05,0,0)
Bullet.Anchored = false
Bullet.Velocity = Vector3.new(0,30,10)
game.Debris:AddItem(Bullet, 3)
end)
--Function call
MakeShell(Gun)
I believe coroutines should be used only if you don’t want that part of the script to affect other parts and vice versa.
2 Likes