Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What is wrong with this script?

Asked by
IcyEvil 260 Moderation Voter
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
2
Answered by 9 years ago

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)

Ad

Answer this question