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

my script wont work ive been searching on YouTube but nothing popped up?

what is wrong with this function

armor.Touched:Connect(function(touchedPart) local humanoid = touchedPart.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.MaxHealth = 200 armor.Position = Vector3.new(torso.Position) end end)

2 answers

armor.Touched:Connect(function(touchedPart) 
	local humanoid = touchedPart.Parent:FindFirstChild("Humanoid")
	if humanoid then 
		humanoid.MaxHealth = 200 
		humanoid.Health = 200 -- set it to 200 because if max health changes health does not change, do this before setting MaxHealth
		armor.Position = torso.Position -- do this because it still return Vector3 value 
	end 
end)

Instead of using Vector3.new just set it to the torso position directly like this:

	armor.Touched:Connect(function(touchedPart)
	    local humanoid = touchedPart.Parent:FindFirstChild("Humanoid")
	    if humanoid then
	        humanoid.MaxHealth = 200
	        humanoid.Health = 200
	        armor.Position = torso.Position -- Replace Vector3 with this
	    end
	end)

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