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

What is wrong with this script?

Im trying to make an Account Age Script, And Ive got An Error That Says

attempt to concatenate local 'AccountAge' (a nil value)

Here is the script

script.Parent.Touched:connect(function(hit)
	if hit.Parent then
		for _,v in pairs(game.Players:GetChildren())do
		local hum = v.Character:findFirstChild("Humanoid")
		if hum then
			local AccountAge = v:findFirstChild("AccountAge")
			h = Instance.new("Hint")
			script.Parent.BrickColor = BrickColor.new("Bright red") 
			h.Parent = game.Workspace
			h.Text = v.Name.." Is "..AccountAge.." Days Old" -- attempt to concatenate local 'AccountAge' (a nil value)
			wait(15)
			h:Destroy()
			script.Parent.BrickColor = BrickColor.new("Black")
		end
	end
	end
	end)

1 answer

✓ Accepted answer

Account Age isn't an object, it's a property.

script.Parent.Touched:connect(function(hit)
    if hit.Parent then
        for _,v in pairs(game.Players:GetChildren())do
        local hum = v.Character:findFirstChild("Humanoid")
        if hum then
            local AccountAge = v.AccountAge
            h = Instance.new("Hint")
            script.Parent.BrickColor = BrickColor.new("Bright red") 
            h.Parent = game.Workspace
            h.Text = v.Name.." Is "..AccountAge.." Days Old" -- attempt to concatenate local 'AccountAge' (a nil value)
            wait(15)
            h:Destroy()
            script.Parent.BrickColor = BrickColor.new("Black")
        end
    end
    end
    end)

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