I do not know how to solve this problem, I want to make it so that the player can damage another player, but I wanted to make a hit on the client and damage on the server, I do not understand how to do this in
txt (to make it convenient) Combat.txt (2.0 KB) - (SERVER SCRIPT) Dmg.txt (182 Bytes) - (LOCAL SCRIPT)
Never handle the hitboxes on the client. I would recommend changing the whole system to almost FULLY rely on the server to handle the hitting and the damaging. But, the simple fix is changing the OnTouch functions parameters.
local remote = game.ReplicatedStorage:WaitForChild("DMG")
function OnTouch(plr, hit, humanoid)
print(hit.Name)
humanoid:TakeDamage(25)
end
remote.OnServerEvent:Connect(OnTouch)
plr is always the first parameter of an OnServerEvent. But again, I would very much recommend changing the handling of checking the touched players and the damaging to solely on the server. The only thing the client should handle is input.
I have to go to bed, got school in the morning (It’s kinda 1 am rn), so I can’t help any further than this.
First of all, you’re sending the OnTouch function to the remote, and im pretty sure you cant send functions through remotes.
So remove the remote:FireServer(OnTouch) lines.
But here is probably what you want: –Local script
function OnTouch(hit, humanoid)
print(hit.Name)
damageRemote:FireServer(humanoid) --Add this line
end
–Server script
local damageRemote = --Add your pathway
local function damagePlayer(player, humanoid)
humanoid:TakeDamage(25)
end
damageRemote.OnServerEvent:Connect(damagePlayer)
I have not tested this but it should take you to the right direction.
Also, use task.wait() instead as its more performant than wait()
Also x2, make sure you do sanity checks on the server with the damage remote/function. An exploiter can easily abuse the example code I wrote. To secure them I would recommend magnitude and cooldown checks on the server and much more.
Play the animation on the client then activate the hitbox when the animation is playing, make sure you have ray cast visuals on in the Raycasthitbox module to see if the rays are actually being created.
Then have a print line to see what the rays are hitting.