Sword Damage script not working

So I’m fixing up this old game that’s been broken due to filtering enabled and overall ROBLOX updates. This (SUPPOSED TO BE SIMPLE) sword script will not deal damage and I have no idea why. I’ve been at this for a few days and I still can’t figure it out. It’s a server script.

If anyone could point me in the right direction, I’d really appreciate it.

Code:

local HIT_DEBOUNCE_TIME = .5
local HIT_DAMAGE = 25
local humHitTimes = {}

function WaitForChild(parent, child)
	while not parent:FindFirstChild(child) do wait() end
	return parent[child]
end

function incrementScore(player)
	local playerScoreTag = WaitForChild(player, "Score")
	playerScoreTag.Value = playerScoreTag.Value + 1
end

local StateManager = WaitForChild(game.Workspace, "StateManager")
local TeamKillTag = WaitForChild(StateManager, "TeamKill")

local Handle=WaitForChild(script.Parent,'*Handle*')

function blow(hit)

	if not hit then return end

	if not script.Parent.Enabled then return end

	local hitChar = hit.Parent
	if not hitChar then return end

	local hitHum = hitChar:FindFirstChild("Humanoid")
	if not hitHum then return end

	local vCharacter = script.Parent.Parent
	if not vCharacter then return end

	local vPlayer = game.Players:playerFromCharacter(vCharacter)
	if not vPlayer then return end

	local otherPlayer = game.Players:playerFromCharacter(hitChar)
	if otherPlayer and (otherPlayer==vPlayer or not TeamKillTag.Value) then return end -- no self-killing (and TK only if it's duel-time)

	local currTime = tick()
	
	if not Handle.hit.IsPlaying then
		Handle.hit.Pitch= math.random()+.5
		Handle.hit:Play()
		delay(.5,function() Handle.hit:Stop() end)
	end

	if not humHitTimes[hitHum] or humHitTimes[hitHum] < currTime - HIT_DEBOUNCE_TIME then
		humHitTimes[hitHum] = currTime
		if hitHum.Health > 0 and hitHum.Health <= HIT_DAMAGE then
			if hitChar.Name ~= "Shredder" then
				incrementScore(vPlayer)
			else
				-- killed the boss; start the death animation!
				workspace.StateManager.ShredderManager.BossDeath:Invoke()
				return
			end
		end
		hitHum:TakeDamage(HIT_DAMAGE)
		wait(.5)
	end
end

Handle.Touched:Connect(blow)

1 Like

Is that a local script? Or A normal script?

I’d recommend you to add a simple animation [ for swinging], and after its done playing, damage the player whom got hit by that handle. You’ll need to use a remote function to fire the server tho.

It’s a server script. The swinging animation is handled via a local script and then called on a server script via remote event.

Alright, this is good. Then you could damage the player on the server aswell. Send a remote with the other players argument [ cus the one is automatically yourself]

1 Like

What’s the game? If you wouldn’t mind sharing.

https://www.roblox.com/games/7173650382/Kingdom-Life-II

Is it this?

prints prints prints! add prints and see where the code halts. if theres no errors then that means its just being stopped by one of those if statements. add prints, see which print it stops at, and check the conditionals for that if.

2 Likes

The old TMNT event game. TMNT Turtle Trouble.