Attempt to Preform arthinect (Add) on nil and number

Module –

local Bar = {}

local Values = {}
function Bar:Add (humanoid,Number,TypeOfBar,Name)

		print(TypeOfBar)
		local att = humanoid:GetAttribute(TypeOfBar)
	humanoid:SetAttribute(TypeOfBar, att + Number)
	

table.insert(Values,TypeOfBar)
table.insert(Values,Name)
table.insert(Values,humanoid)
table.insert(Values,Number)

end

function Bar:GetValue ()
	return Values
end

return Bar`

Script: `

local Module = require(game.ReplicatedFirst.BarsModule)
script.Parent.Touched:Connect(function(h)

	if h.Parent:FindFirstChild("Humanoid") then
		
		local human = h.Parent:FindFirstChild("Humanoid")
		while wait() do
					Module:Add(human,10,"Oxygen",script.Parent.Name)
			if script.Parent.TouchEnded then
				break
			end
		end

	end
end)`
2 Likes

No such attribute by the name of what’s stored under TypeOfBar exists

1 Like

what do you mean can you rephrase this?

The humanoid has no attribute by the name of script.Parent.Name

typeofbar is recorded in the script and the type is “oxygen”

the place where the error takes place is Module:

humanoid:SetAttribute(TypeOfBar, att + Number)

this code works perfectly in my other scripts

Too bad. It’s not working here. Work out why the attribute is not there

1 Like

Ok ill try to figure it out thanks for the help tho

if you have an idea tell me! I will try it