So basically i have made a hit system that will do an event to be fired for the damage and the bullet hole but its not basically firing each time i am clicking here is the code (i remove some stuff in it):
local function new_bullet() ---this function is somehow not firing the event if u spam clicking
if not shooting then
shooting = true
local ray = Ray.new(gun["Butterfly knife"].Blade.Position, (Mouse.Hit.p - gun["Butterfly knife"].Blade.CFrame.p).unit * 10)
local part, pos = workspace:FindPartOnRayWithIgnoreList(ray, {cam,char, ignore})
local damage = 15
if part then
Events:FireServer(part,pos,damage) ---This not firing all the time :/
end
shooting = false
end
end
local shootAnimation = gun.Anim:LoadAnimation(game.ReplicatedStorage.WeaponsModules.Knife.shoot)
Mouse.Button1Down:Connect(function() --- will call the function along with firing the event This is where its getting problems
if humanoid.Health <= 0 then
return
end
new_bullet()
shootAnimation:play()
end)
Here is The OnServerEvent script:
local RS = game.ReplicatedStorage
local event = RS.Shooting
event.OnServerEvent:connect(function(plr, part, pos, damage)
print("found!")
if part.Parent:FindFirstChild("Humanoid") then
local humanoid = part.Parent.Humanoid
if humanoid.Health > 0 then
humanoid:TakeDamage(damage)
end
else
local bullet = RS.bullet:Clone()
bullet.Position = pos
bullet.Parent = workspace.ignore
game.Debris:AddItem(bullet, 1)
end
end)
i have did several test but it seem that the problem is comming from the OnServerEvent but i dont see where it
i couldnt get a recording sorry for that