Rays cannot register moving players

Sorry in advance if this has been posted before.

The weapons in my game works by raycasting since that is the best option for now, since the .Touched event is horrible in this sort of scenario.
But of course, I wish the rays actually did function and register moving players.

Context: The weapons cast 26 rays right now(using a server script), 10 from the head towards to the mouse position and 16 from the torso spreading like a shotgun.

Still, has no effect on registering moving players. Any kind soul here to help me out? Here is a part of the ray function so maybe it sorts stuff out.

local function raycast(unitray)
	assert(unitray,"Unit ray not provided.")
	local ray = workspace:Raycast((char.Head.Position+(char.Head.CFrame.LookVector)),unitray.Direction * hitscandist, rayparams)
if ray then
		if ray.Instance then
			if ray.Instance.Parent.Name == "BackstabHitbox" then
				local inst = ray.Instance
				print(inst.Name)
				local mdl  = inst.Parent.Parent
				return mdl, true
			else
				local inst = ray.Instance
				local mdl = inst.Parent.Parent
				local mdl = nil
				if not inst.Parent:IsA("WorldRoot") then
					if inst.Parent:IsA("Model") then
						mdl = inst.Parent
					elseif inst.Parent:IsA("Accessory") then
						mdl = inst.Parent.Parent
					else
						mdl = nil
					end
				end
				if mdl then
					if mdl ~= char then
						if mdl:FindFirstChild("Humanoid") then
							return mdl, false
						end
					end
				else return nil end
			end
		end
	end
end

As always, any help is appreciated.

The problem was client-server replication lag. Raycasting from the client fixed the problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.