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)
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)
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.