BedWars Creative
  • 📜Changelog
  • ðŸŽĻSandbox Mode
  • 🊓WorldEdit Commands
  • ðŸ›ĄïļWorldGuard System
  • 🍊BedWars Scripting
    • 🚜Services
      • ðŸŽ―AbilityService
      • ðŸ“ĢAnnouncementService
      • ðŸ§ąBlockService
      • ðŸ”ĪChatService
      • ⚔ïļCombatService
      • 🌊ïļDisasterService
      • 🊅DataStoreService
      • ðŸŠĻEntityService
      • ðŸ”ĨForgeService
      • 🏭GeneratorService
      • ðŸ‘Đ‍🚀GravityService
      • âŒĻïļInputService
      • 🎒InventoryService
      • 💎ItemService
      • 🛏ïļMatchService
      • â„đïļMessageService
      • 🎁ModelService
      • ðŸĶĪMountService
      • 🏄‍♂ïļPlayerService
      • 🏗ïļPartService
      • 🎉ParticleService
      • 👆PromptService
      • 💰ShopService
      • ðŸ“ŧSoundService
      • 🊄StatusEffectService
      • 🚁VehicleService
      • ðŸšĐTeamService
      • ðŸĨ‡UIService
    • ðŸĪEvents
      • BeforeProjectileLaunched
      • BlockPlace
      • BlockBreak
      • BedAlarmTriggered
      • ConsumeItem
      • Enchant
      • EntityDamage
      • EntityDeath
      • EntitySpawn
      • Forged
      • InventoryItemAdded
      • ItemPurchase
      • MatchStart
      • PlayerChatted
      • PlayerAdded
      • PlayerRemoving
      • PlayerDropItem
      • PlayerPickupItem
      • ProjectileLaunched
      • ProjectileHit
      • StatusEffectAdded
      • StatusEffectRemoved
      • WeaponSwing
      • TeamUpgradePurchased
      • TeamUpgradeEraPurchased
      • Telepearled
      • UseAbility
    • ðŸ“ĶObjects
      • AbilityConfig
      • Block
      • Entity
        • ImageEntity
        • KitEntity
        • CreatureEntity
      • Generator
      • Knockback
      • Leaderboard
      • MatchState
      • Model
      • ParticleEmitter
      • Part
      • Player
      • Prompt
      • ProgressBar
      • TextLabel
      • Team
    • 📚Types
      • AbilityType
      • AbilityInputType
      • CreatureType
      • DisasterType
      • EnchantType
      • ItemType
      • KitType
      • ModelType
      • MountType
      • VehicleType
      • ProjectileType
      • SoundType
      • StatusEffectType
      • TeamUpgradeEraType
      • TeamUpgradeType
      • MatchRole
    • ⚙ïļUtilities
      • require
      • math
      • pairs & ipairs
      • print & error
      • os
      • string
      • table
      • task
      • tick
      • tostring & tonumber
      • wait
Powered by GitBook
On this page
  1. BedWars Scripting
  2. Services

TeamService

Service for handling team assignments.

Example usage:

-- Gamemode: Tag
-- Hitting players makes them join your team.
-- Once everyone is on the same team the game ends.
Events.EntityDamage(function(event)
    -- Can only tag players
    if not event.entity:getPlayer() then
        return
    end
    -- Make sure the tagger is a player
    if (not event.fromEntity or not event.fromEntity:getPlayer()) then
        return
    end
    
    local attackerTeam = TeamService.getTeam(event.fromEntity:getPlayer())
    TeamService.setTeam(event.entity:getPlayer(), attackerTeam)
    
    -- Check that all teams besides the attackerTeam are empty
    -- If so give win to attacker team
    local gameOver = true
    for i, team in ipairs(TeamService.getAllTeams()) do
        if (team == attackerTeam) then
            continue
        end
        
        -- If another team has players the game is not over
        if #team:getInGamePlayers() > 0 then
            gameOver = false
            break
        end
    end
    
    -- Give out win
    if gameOver then
        MatchService.endMatch(attackerTeam)
    end
end)

Functions

Returns player's team. If player is not on a team this will return nil.

Change the team of a player.

Returns table of all teams.

Returns the block instance of the given team's bed.

PreviousVehicleServiceNextUIService

Last updated 1 year ago

getTeam(player: Player): | nil

setTeam(player: , team: )

getAllTeams(): []

getTeamBed(team: ):

🍊
🚜
ðŸšĐ
Team
Player
Team
Team
Team
Block