So I have a gun that I am making and it was firing and showing the bullets coming out a few moments ago, but now I did something to make it stop showing the bullets.
So I have a local script inside the "Pistol" Tool. This script is as follows
-- Replicated Storage
local ShootEvent = game.ReplicatedStorage:WaitForChild("ShootEvent")
-- Player
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
-- Pistol Related Variables
local Ammo = script.Parent.Ammo
local MaxAmmo = script.Parent.MaxAmmo
local BulletVelocity = 25
local FireRate = .1
local BulletDamage = 15
local Pistol = script.Parent
local Reloading = false
local Barrel = script.Parent.Barrel
local Difference = 0
local StopFiring = false
-- Pistol Special Features
local PistolGui = script.Parent.PistolGui
-- When Equipped
Pistol.Equipped:Connect(function()
PistolGui.Parent = player.PlayerGui
PistolGui.PistolFrame.AmmoAmount.Text = ""..Ammo.Value.."/"..MaxAmmo.Value
Pistol.Barrel.Anchored = false
Pistol.Handle.Anchored = false
-- Player Clicks down to fire (Semi Automatic without While loop)
Mouse.Button1Down:Connect(function()
if StopFiring == false then
if Ammo.Value <= 0 then
StopFiring = true
if MaxAmmo.Value > 0 and Reloading == false then
-- Reload
elseif MaxAmmo.Value <= 0 then
-- No Ammo
end
elseif Ammo.Value > 0 then
local head = game.Workspace[player.Name].Head.CFrame.lookVector
local mouse = CFrame.new(game.Workspace[player.Name].Head.Position,Mouse.Hit.p).lookVector
ShootEvent:FireServer(Barrel, mouse,"Pistol", BulletVelocity, BulletDamage)
Ammo.Value = Ammo.Value - 1
PistolGui.PistolFrame.AmmoAmount.Text = ""..Ammo.Value.."/"..MaxAmmo.Value
wait(FireRate)
end
end
end)
end)
-- Unequipped Pistol
Pistol.Unequipped:Connect(function()
PistolGui.Parent = Pistol
end)
I have the Server Side Code that is called when the gun shoots:
-- Replicated Storage For Shooting
local ShootEvent = game.ReplicatedStorage:WaitForChild("ShootEvent")
ShootEvent.OnServerEvent:Connect(function(player, Barrel, Mouse, BulletName, BulletVelocity, BulletDamage)
local Bullet = game.ServerStorage.Bullets:WaitForChild(BulletName):Clone()
Bullet.Position = Barrel.Position
Bullet.Parent = game.Workspace
Bullet.Velocity = Mouse * BulletVelocity
end)
Thank you.
Updated Information: The OnServerEvent Listener isn't being ran. I put print statements in it with new line characters and it still would not print. It was working before so I didn't want to bring this up but I will just for the sake of reference: The server script is a module script (Not using the module part for this but I just put it in there for organization).
SOLUTION: So since the server replicated storage code was in a module script it wasn't working. I moved it to a normal script and it showed the part right away. Not sure why it was working before with it in there but whatever.

2 comments
Anything in the output?
Nothing in the output