Should I use remote event for swords?

I’m currently working on a sword. How should I set up the code?
Should I use animations and debounce on the client and send a remote event to the server?
like this:
Client:

local Debounce = true
sword.Touched:connect(function(hit)
	if player then
		if Debounce == true then
			Debounce = false
			RemoteEvent:FireServer(player, sword)
			wait(1)
			Debounce = true
		end
	end
end)

Server:

RemoteEvent.OnClientEvent:connect(function(player, Attackedplayer, sword)
	local Damage = game.ReplicatedStorage.SwordValues:FindFirstChild(sword).Value
	Attackedplayer:Damage(Damage)

end)

How could I be sure exploiters can’t exploit with the sword?

1 Like

You can use RaycastHitbox to detect when the sword hits something and check whether the player who was hit is within reasonable range, on the server

2 Likes

You should handle debounces, hitbox, and damage all on the server. Treat the remote event to the server like a request from the client to the server. (Client asking the server if they can use the sword) Handle animations on the client as it automatically replicates.

1 Like

thank you, I will do it with the RayCastHitbox thing

I will use this, thank you! Do you think I should rather use the Making a Deadly Part (The Easy/Lazy Way) or Making a Deadly Part (Intermediate Way) Tutorial??

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