Below is the script I am using to tally points for my game, it's almost complete but I've run into a small problem of connecting the gottem() function to an Event listener which is watching to see if the script.Parent gets a new listener which is a Folder. Please help!
local sP = script.Parent
local amt = 0
local function gottem() -- adds three values and displays them
local descendants = sP:GetDescendants()
for index, descendant in pairs(descendants) do -- adds values
if descendant:IsA("NumberValue") and descendant.Name == "Points" then
amt = descendant.Value + amt
end
end
print(amt)
local totalWins = sP:FindFirstChild("totalWins")
local totalPoints = sP:FindFirstChild("totalPoints")
local totalStars = sP:FindFirstChild("totalStars")
if totalWins then -- changes the display
local amt = totalWins
totalWins = sP:FindFirstChild("totalWins").Value == amt
end
end
sP.DescendantAdded:connect(function(p)
if p:IsA('Folder') then
-- plz help lol
end
end)
