Hello there,
I was making a combat system using raycasting.When i test it works fine( on the normal studio test) But if i got in multiplayer the raycast isnt accurate at all infact it dosent detect the enemy player at all!.How do i fix this,Help will be appriciated
thanks, 
The script would be handy to see 
local raycasthitbox = {}
local typ = nil
raycasthitbox.Hitboxcombat = function(etroso,studs,damage)
if studs == nil then
warn("PROVIDE A STUD DISTANCE")
end
local Character = etroso.Parent
local RayCastPara = RaycastParams.new()
RayCastPara.FilterDescendantsInstances = {Character}
RayCastPara.FilterType = Enum.RaycastFilterType.Blacklist
local Eyes = Character.HumanoidRootPart.CFrame.LookVector
local Distance = studs
local RayHitBox = workspace:Raycast((Character.HumanoidRootPart.CFrame).p, Eyes * Distance, RayCastPara)
if RayHitBox then
if RayHitBox.Instance.Name =="Blocking" then
warn("HEshel")
local attackedHumanoid = RayHitBox.Instance.Parent
local blockVal = RayHitBox.Instance.Parent:FindFirstChild("BlockingValue")
if blockVal.Value == 1 then
blockVal.Value = 0
RayHitBox.Instance:Destroy()
local value = Instance.new("IntValue")
value.Name="combo"
value.Parent = attackedHumanoid
game.Debris:AddItem(value,3)
local Player = game.Players:FindFirstChild(etroso.Parent.Name)
game.ReplicatedStorage.Combat:FireClient(Player,true)
else
blockVal.Value = blockVal.Value-1
local Player = game.Players:FindFirstChild(etroso.Parent.Name)
game.ReplicatedStorage.Combat:FireClient(Player,false)
end
else
if RayHitBox.Instance and RayHitBox.Instance.Parent:FindFirstChild("Humanoid") then
local attackedHumanoid = RayHitBox.Instance.Parent
if damage == nil then
else
if attackedHumanoid:FindFirstChild("Candie") then
attackedHumanoid.Humanoid:LoadAnimation(script.Death):Play()
wait(1)
local sound = Instance.new("Sound")
sound.Parent = attackedHumanoid.HumanoidRootPart
sound.RollOffMaxDistance = 20
sound.SoundId="rbxassetid://5139955762"
spawn(function()
for _, part in pairs(attackedHumanoid:GetChildren()) do
if part:IsA("BasePart") then
local goal={Transparency =1}
local info = TweenInfo.new(.7)
game:GetService("TweenService"):Create(part,info,goal):Play()
end
end
end)
sound:Play()
local effect = game.ReplicatedStorage:WaitForChild("dies"):Clone()
effect.Parent = attackedHumanoid.HumanoidRootPart
effect:Emit(400)
game.Debris:AddItem(effect,3)
else
attackedHumanoid.Humanoid:LoadAnimation(script.hit):Play()
local effect = game.ReplicatedStorage:WaitForChild("Hit effect").Center:Clone()
effect.Parent = attackedHumanoid.HumanoidRootPart
for _, part in pairs(effect:GetChildren()) do
part:Emit(1)
end
game.Debris:AddItem(effect,2)
local value = Instance.new("IntValue")
value.Name="combo"
value.Parent = attackedHumanoid
game.Debris:AddItem(value,1)
attackedHumanoid.Humanoid:TakeDamage(damage)
end
end
typ = true
return typ,attackedHumanoid
else
typ = false
return typ
end
end
end
end
Sorry if indentation is really bad the way roblox handles tabs is weird.
You likely have to move the script to the client-side and then fire a remote event to the server when a hit lands. Although this is annoying to have to make, client side updates much faster and therefore is more accurate. This is assuming your code works…