im trying to make a gun and I want the body position of the character to face where ever the mouse clicks so that the bullets looks realistic. here is my gun script. i dont know how to script i just got this script from alvinblox gun tutorial video.
script.Parent.Fire.OnServerEvent:Connect(function(player,mousePos)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(script.Parent.Handle.Position,(mousePos - script.Parent.Handle.Position)*300,raycastParams)
if raycastResult then
script.Parent.Gunshot:Play()
local hitPart = raycastResult.Instance
local model = hitPart:FindFirstAncestorOfClass("Model")
if model then
if model:FindFirstChild("Humanoid") then
model.Humanoid.Health -= 25
end
end
end
end)
