I'm using a script (not a local script since it didn't work very well) to change the Humanoid health when the tool is activated, but for some reason its not working.

The script:

local animations = {"4220380816"}
enabled = true


function onActivated()
	if not enabled  then
		return
	end
	
	enabled = false
	local Tool = script.Parent
	local Char = Tool.Parent
	local random = animations[math.random(1,#animations)]
		
	local anim = Instance.new("Animation")
	anim.AnimationId = "http://www.roblox.com/asset/?id="..random
		
	local track = Char.Humanoid:LoadAnimation(anim)
	track:Play()
		
	script.Parent.Handle.ActivatedSound:Play()
	wait(3)
	Char.Humanoid.Health = Char.Humanoid.Health + 30
	wait(0.5)
	script.Parent:Destroy()
end

script.Parent.Activated:connect(onActivated)

The animation works very well, but when changing the Humanoid health, nope.

5 comments

0

Humanoid object should go with localplayer script in the tool...

0

Humanoid object should go with localplayer script in the tool...

0

Do u mean to test the same code with a LocalScript?

0

yeah try it

0

I tried it but i don't get good results, when i activate the tool, i get some health but then it goes to my normal health.