I’m trying to make a leaderstat value go up when a function is called. The function that is being called can’t get the player, so there’s a function embedded in another function. I’m a bit new to scripting, and am wondering why this won’t work:
local count = script.Parent.Count
script.Parent.Touched:Connect(function(hit)
if hit.Name == "SpecialPinkBall" or hit.Name == "GodPinkBall" or hit.Name == "SmokingCharcoal" or hit.Name == "BigSmokingCharcoal" or hit.Name == "SmokingGodBall" or hit.Name == "FlamingPinkCrate" or hit.Name == "FlamingSparklesPinkCrate" or hit.Name == "GiantBlueCrate" or hit.Name == "GiantGlowingBlueCrate" or hit.Name == "GiantGodlyYellowShinyBall" or hit.Name == "GodlyYellowShinyBall" or hit.Name == "TheBadGodlyCrate" or hit.Name == "TheGoodGodlyCrate" or hit.Name == "Stinky" or hit.Name == "Bad" or hit.Name == "SparklingNeonGreenBall" or hit.Name == "GiantNeonGreenBall" or hit.Name == "BadBall" or hit.Name == "SmokingBadBall" or hit.Name == "WhiteFireBlueBall" or hit.Name == "GodlyBlueBall" or hit.Name == "GiantGodlyBlueBall" or hit.Name == "GoodGodlyBlueBall" or hit.Name == "AGodlyBall" or hit.Name == "GiantGodlyInsaneGodBall" then
script.Parent.BrickColor = BrickColor.new("Really red")
wait(.5)
script.Parent.BrickColor = BrickColor.new("Lime green")
print("Boy")
hit:Destroy()
script.Parent.Success:Play()
count.Value = count.Value + 1
game.Workspace.PackageScreen.Sign.SurfaceGui.SIGN.Text = "Completed Packages: " .. count.Value
game.Players.PlayerAdded:Connect(function(player)
player.leaderstats.Packages.Value = player.leaderstats.Packages.Value + 1
end)
end
end)
You could store the names in a table then use table.find to see if the name is in the table. This is way better to write and read than that eyesore (my vocabulary isn’t the best)