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

attempt to connect failed : passed value is not a function. can somebody please help?

Asked by 2 years ago
local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    -- Example of a IntValue
    local points = Instance.new("IntValue")
    points.Name = "money"
    points.Value = 0
    points.Parent = leaderstats


    local pointsi = Instance.new("IntValue")
    pointsi.Name = "iron"
    pointsi.Value = 0
    pointsi.Parent = leaderstats
end
-- Run onPlayerJoin when the PlayerAdded event fires
game.Players.PlayerAdded:Connect(onPlayerJoin)

workspace["Iron ore"].Rock.Touched:Connect(what)

function what ()
        return pointsi.value+1
end

1 answer

Log in to vote
0
Answered by
Hypoxla 125
2 years ago
Edited 2 years ago

You need to move the function 'what' above when it is called. The reason you're getting the error is because the function hasn't been declared, so it can't find a function to call.

function what ()
    return pointsi.value+1
end

workspace["Iron ore"].Rock.Touched:Connect(what)

Let me know if any other problems occur.

Ad

Answer this question