Hello Everyone. I’m making an FPS game right now, and I need to make Bullet Shell Drop for it. So, I’ve made a script that drops the shell when player shoots. When I tested it, I can’t see any shell.
-
What is the issue? I don’t have any error, and I can see that Shell is cloning to the workspace when player shoots. But in the game, you can’t see any dropping shell.
-
What solutions have you tried so far? I tried everything, but nothing. I’ve also tried printing in output everything, but still nothing.
I have one ServerScript in ServerScriptService, and one LocalScript in StarterPlayerScripts that makes Gun Framework.
Also, I have Bullets and Shell in ReplicatedStorage.
ServerScript:
rs.Remotes.Events:WaitForChild("Shoot").OnServerEvent:Connect(function(player, muzzlePos, lookPos, bulletType, shellCF, shellPos, damageSmall, damage, headshot)
if player.Character then
local sound = player.Character.Torso:FindFirstChild("FireSound")
if sound then
sound:Play()
end
local bullet = rs.Bullets[bulletType].Bullet:Clone()
bullet.Parent = workspace
bullet.CanCollide = false
bullet.Anchored = false
bullet.CFrame = CFrame.new(muzzlePos, lookPos)
local shell = rs.Bullets[bulletType].Shell:Clone()
shell.Parent = workspace
shell.Position = shellPos
shell.Velocity = (Vector3.new(shell.CFrame.LookVector * 30) + (shellCF.RightVector * -8) + Vector3.new(0,30,0))
debris:AddItem(shell, 10)
local bulletPos = bullet.Position
bullet:SetNetworkOwner(player)
shell:SetNetworkOwner(player)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Parent = bullet
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.Velocity = (bullet.CFrame.LookVector * 100)
bullet.Touched:Connect(function(hit)
local range = 300
local params = RaycastParams.new()
local stop = (hit.Position - muzzlePos).Unit * range
local result = workspace:Raycast(muzzlePos, stop, params)
if result then
if hit.Parent ~= player.Character then
bullet:Destroy()
if hit then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Name == "Head" then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(headshot)
elseif hit.Name == "Torso" then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(damage)
else
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(damageSmall)
end
end
end
end
if hit.Material == Enum.Material.SmoothPlastic then
bullet:Destroy()
if hit.Name == "Glass" then
local BreakingPoint = hit:FindFirstChild("BreakingPoint")
if BreakingPoint and BreakingPoint:IsA("Attachment") then
BreakingPoint.WorldPosition = bulletPos
BreakingPoint.Position = Vector3.new(0, BreakingPoint.Position.Y, BreakingPoint.Position.Z)
partFracture.FracturePart(hit)
end
end
end
if hit.Material == Enum.Material.Plastic then
addHole(result)
bullet:Destroy()
else
addHole(result)
bullet:Destroy()
end
end
end)
wait(15)
bullet:Destroy()
end
end)
LocalScript:
local framework = {
inventory = {
"M4A1";
"M9";
"Knife";
"Frag";
};
module = nil;
viewmodel = nil;
currentSlot = 1;
}
function shoot()
if framework.module.fireMode == "Semi" then
fireAnim:Play()
framework.module.ammo -= 1
crosshair:Shove(crosshair.Radius * 2.5)
recoil:shove(Vector3.new(1.8, 0, 0))
local bulletType = framework.module.bulletType
rs.Remotes.Events:WaitForChild("Shoot"):FireServer(framework.viewmodel.Muzzle.Position, mouse.Hit.p, bulletType, framework.viewmodel.Shell.CFrame, framework.viewmodel.Shell.Position, framework.module.damageSmall, framework.module.damage, framework.module.headshot)
debounce = true
wait(framework.module.debounce)
debounce = false
elseif framework.module.fireMode == "Full Auto" then
isShooting = true
end
end
If someone helps, it would be really appreciated! Thanks.