Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My TakeDamage() script isn't working?

So'm i'm using this sword from roblox battle, and i'm trying to make it only attack a dummy a made. This is so you can't kill other players in the lobby. The dummy's name is Dummy. I don't get a error, it just doesn't do anything to the dummy. Help?

This is only a part of the script, not the full thing.

handle.Touched:connect(function(hit)
	if equipped and character and humanoid and humanoid.Health > 0 and humanoid.Name == "Dummy" and not hit:isDescendantOf(character) then
		local targethumanoid = hit.Parent:FindFirstChild("Humanoid")
		if targethumanoid and targethumanoid.Health > 0 and not hithumanoids[targethumanoid] then
			hithumanoids[targethumanoid] = true
			
			for _, v in pairs(targethumanoid:GetChildren()) do
				if v and v.Name == "creator" then
					v:remove()
				end
			end
			local tag = Instance.new("ObjectValue")
			tag.Name = "creator"
			tag.Value = player
			debris:AddItem(tag, 3)
			tag.Parent = targethumanoid

			local damagemultiplier = 1

			targethumanoid:TakeDamage(damage * (combo + 1) * damagemultiplier)
		end
	end
end)

2 comments

0

I attempted to do so at line 2, it's a long line.

0

Where is humanoid and character and equipped, etc, defined?

1 answer

@BlueTaslem

tool.Equipped:connect(function()
	equipped = true
	lastclick = tick()
	combo = 0
	character = tool.Parent
	player = game.Players:GetPlayerFromCharacter(character)
	humanoid = character:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.WalkSpeed = 16 * speedboost
	else
		character = nil
	end
end)

1 comment

0

I don't think BlueTaslem uses roblox tbh.

This discussion is preserved as it was. New answers, comments, and votes are closed.