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

Whats Wrong With This Script, I Can Swing The Weapon But It Won't Deal Damage?

I can swing the weapon and from what I've learned this should work but it wont deal damage, it is a tool named StickWeapon with a model named Stick


local Stick = script.Parent
local canDamage = false

local function onTouch(otherpart)
	if not humanoid then
		return
	end
	if humanoid.Parent ~= Stick.Parent and canDamage then
		humanoid:TakeDamage(10)
	else
		return
	end
	canDamage = false
end

local function slash()
	local str = Instance.new("StringValue")
	str.Name = "toolanim"
	str.Value = "Slash"
	str.Parent = Stick
	canDamage = true
end

Stick.Activated:Connect(slash)
StickWeapon.Handle.Touched:Connect(onTouch)

2 comments

0

put it in a script box.

0

try: Humanoid.Health = Humanoid.Health - 10

2 answers

try: Humanoid.Health = Humanoid.Health - 10

1 comment

0

I tried this and unfortunately it didnt work for it, Thanks though

I mean. Why don't you just do this:

script.Parent.Touched:Connect(function(hit) local Humanoid = hit.Parent:FindFirstChild("Humanoid") if (Humanoid ~= nil) then

Humanoid:TakeDamage(10)

   end

end)

1 comment

0

because i am using a model i made and it has to use animation code in it aswell not just that

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