Make script work only on specific team

local Char = script.Parent

local SoundFolder = game.ServerStorage.DeathSounds
	local Sounds = SoundFolder:GetChildren()

local Humanoid = Char:WaitForChild("Humanoid")
local HumanoidRootPart = Char:WaitForChild("HumanoidRootPart")

Humanoid.Died:Connect(function()
	local ChosenSound = Sounds[math.random(1,#Sounds)]:Clone()
	ChosenSound.Parent = HumanoidRootPart
	ChosenSound:Play()
	HumanoidRootPart:WaitForChild("Died"):Destroy()
end)

Hi all, this is a script I have for a random death sound, where on death, a sound from the DeathSounds folder plays.

How should I make this script check if the player who dies is on a specific team for the script to work? This script is located in StarterCharacterScripts

1 Like

The player instance has variables called Team (:Team) and TeamColor (:BrickColor), both can be used to check what team a player is on.

https://create.roblox.com/docs/reference/engine/classes/Player#Team
https://create.roblox.com/docs/reference/engine/classes/Player#TeamColor

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.