Take this as a question and not a request.
How would I detect when someone captures a flag on a team because I'm making a CTF gamemode. What events would I use to achieve this.
My leaderboard script
local stats = {"value", "Omegite", "Captures"} game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" for _, stat in pairs(stats) do Instance.new("IntValue", leaderstats).Name = stat end end)
Try this script:
function findAllFlagStands(root) local c = root:children() for i=1,#c do if (c[i].className == "Model" or c[i].className == "Part") then findAllFlagStands(c[i]) end if (c[i].className == "FlagStand") then table.insert(stands, c[i]) end end end function hookUpListeners() for i=1,#stands do stands[i].FlagCaptured:connect(onCaptureScored) end end function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local captures = Instance.new("IntValue") captures.Name = "Captures" captures.Value = 0 captures.Parent = stats while true do if newPlayer.Character ~= nil then break end wait(5) end stats.Parent = newPlayer end function onCaptureScored(player) local ls = player:findFirstChild("leaderstats") if ls == nil then return end local caps = ls:findFirstChild("Captures") if caps == nil then return end caps.Value = caps.Value + 1 end findAllFlagStands(game.Workspace) hookUpListeners() game.Players.ChildAdded:connect(onPlayerEntered)