I am making an FPS game. I've made the guns but there is one problem; Every time I shoot a little bit too low, it will either shoot straight from the ground, or just shoot from the ground into the ground instead of the FirePart inside of the gun. Here's a video showing the problem (Please read description and have subtitles on): https://youtu.be/os99udWOqEI
Here is the where the shoot event gets fired from a local script:
raycastEvent:FireServer(mouse.Hit.Position, weapon:WaitForChild(weapon.Name):WaitForChild("FirePart").Position, weapon:GetAttribute("Damage"), false)
Here is the scripts that receives the event when it gets fired (I shortened it down a bit for this question):
local raycastEvent = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("RaycastEvent") raycastEvent.OnServerEvent:Connect(function(player, endPos, startPos, damage, aimMode) local params = RaycastParams.new() params.FilterType = Enum.RaycastFilterType.Blacklist params.FilterDescendantsInstances = {player.Character} local raycastResults raycastResults = workspace:Raycast(startPos, (endPos - startPos).unit * 100, params) local character = player.Character or player.CharacterAdded:Wait() local head = false if raycastResults then local part = raycastResults.Instance local pos = raycastResults.Position local humanoid = part.Parent:FindFirstChild("Humanoid") print(part.Name) if humanoid then if part.Name == "Head" then head = true humanoid:TakeDamage(damage*2) else head = false humanoid:TakeDamage(damage) end end end end)
If you need anymore information please ask me. Thanks for reading!