What do you want to achieve? I’m trying to fire a remote event to my server script in my tool by checking whether the RayCast has hit another player object. The local script fires the remote event, however, the server script doesn’t receive the fired event…
Anyway to fix this?
I’ve also used the “RaycastHitboxV4” Module script by @TeamSwordphin for the hitboxes.
The RemoteEvent has already been defined
Explorer Screenshot
Local Script
--When we hit someone
local function onRayResult(hit, humanoid)
if humanoidDebounce[humanoid] == true then
return "hit object is on cooldown"
end
humanoidDebounce[humanoid] = true
local distance = (clientRoot.Position - humanoid.Parent.PrimaryPart.Position).Magnitude
meleeEvent:FireServer(humanoid, hit, distance)
wait(swingTime)
humanoidDebounce[humanoid] = false
end
-- Connections
hitbox.OnHit:Connect(onRayResult)
tool.Equipped:Connect(onEquip)
tool.Unequipped:Connect(onUnequip)
tool.Activated:Connect(onClick)
Server Script
-- Handle Damage Dealing and Anti Exploit
event.OnServerEvent:Connect(function(plr, hitHum, hit, clientDist)
print("Fired server")
local serverDist = (plr.Character.PrimaryPart.Position - hitHum.Parent.PrimaryPart.Position).Magnitude
if clientDist - serverDist > bladeLength + 5 then
plr:Kick("Your blade reach is larger than usual. You either have extremely high ping, or are exploiting.")
end
local critChance = math.random(1, 5)
if critChance == 1 then
-- If crit
hitHum:TakeDamage(critDamage)
else
-- If not crit
hitHum:TakeDamage(damage)
end
end)
Thanks!