I have a basic gun script. I'm using raycast to make a bullet and have the params ignore my character. For some reason though, the gun only fires have the time when it is at certain angles and I don't know why. (Note: it is a server issue because I tested and the client detects the input and fires the event)
function for the gun shooting:
fired.OnServerEvent:Connect(function(plr, target : Instance, pos : Vector3)
local params = RaycastParams.new()
params.FilterDescendantsInstances = {plr.Character}
params.FilterType = Enum.RaycastFilterType.Exclude
params.IgnoreWater = true
if deb == false and reloading == false then
if bulletsLeft > 0 then
if target then
local result = workspace:Raycast(tool.Shoot.Position, pos.Position - tool.Shoot.Position, params)
deb = true
if result then
rayVis(tool.Shoot.Position, result.Position)
if result.Instance then
if result.Instance.Parent:FindFirstChild("Humanoid") then
local hum = result.Instance.Parent:FindFirstChild("Humanoid")
hum:TakeDamage(10)
end
end
shotSound:Play()
end
bulletsLeft -= 1
task.wait(SHOT_DELAY)
deb = false
end
end
end
end)
** You are now Level 1! **