I have a punch script but it only damages on client side and im not sure how to make it server side

local canDoDmg = false
local dmg = 25 
local db = false

local Plr = game.Players.LocalPlayer
local strength = Plr.leaderstats.strength
local rb = Plr.leaderstats.rebirths
local UserInputService = game:GetService("UserInputService")
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://6214482685"
local track = Humanoid:LoadAnimation(Anim)

UserInputService.InputBegan:Connect(function(InputObject)
	if InputObject.UserInputType == Enum.UserInputType.MouseButton1 and db == false then 
		track:Play()
		canDoDmg = true
		db = true

		script.Parent.RightHand.Touched:connect(function(hit)
			if hit.Parent.Humanoid and canDoDmg == true then
				local TotalDamage = strength.value -- default value with 0 rebirths

				if rb.Value > 0 then
					TotalDamage *= rb.Value
				end

				hit.Parent.Humanoid:TakeDamage(TotalDamage)
			end
		end)
		delay(1, function()
			canDoDmg = false
			db = false
		end)
		wait(10)
	end
end)

2 comments

0

I'll check it out thank you