gun gun gun etc…
anyway, someone told me i had to use raycasting instead.
so here is a server script with target being the mouse.hit.Position
Connection.OnServerEvent:Connect(function(plr,Target)
print("Fired!!!")
local Direction = Tool.Handle.Position - Target
local RayCastParams = RaycastParams.new()
RayCastParams.FilterDescendantsInstances = {
plr.Character
}
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
CreateProjectile(Direction,Target)
local Results = workspace:Raycast(Tool.Handle.Position,Direction * Range,RayCastParams)
print(Results)
if Results.Instance then
local Character = Results.Instance.Parent
local PossibleHumanoid = Character:FindFirstChildWhichIsA("Humanoid")
if PossibleHumanoid then
PossibleHumanoid:TakeDamage(175)
end
end
end)
now here’s my problem:
raycasting returns nil, and i don’t know why.
it errors at the if statement because there’s no result.
(btw createprojectile is just a function above for cosmetic stuff like it creates a ball and tweens it the deletes it after a few seconds)
thanks in advance!