How would I make a script in a part that damages a player on a certain team?
Well, since the post doesn't say answered, and maybe you don't know how to adapt joshthegamer456's script, here it is
Just like joshthegamer456 said, just use player.Team
The script goes inside the part that will be touched
local DamagePerTouch = 25 -- How much damage per touch will it deal local CooldownPerTouch = 0.5 -- How much time in seconds to be able to damage again local TeamName = "Team Name Here" -- The exact name of the team local part = script.Parent local Team = game.Teams[TeamName] active = true function OnTouch(hit) local plr = hit.Parent if plr:FindFirstChild("Humanoid") then local user = game.Players:GetPlayerFromCharacter(plr) if user.Team == Team and active == true then active = false plr.Humanoid:TakeDamage(DamagePerTouch) wait(CooldownPerTouch) active = true end end end part.Touched:Connect(OnTouch)
Ambiguity can be a killer!
Do you mean: A part that damages a player if the player is on a specific team
or
A part that damages a specific player on a specific team?
Futhermore, the lack of detail in your question makes it hard for me to answer your question with full code. Do you want it to be when it's clicked or when it's touched, does a specific player have to touch it? Detail is key.
No matter what your question is, it can be solved with the Player.Team
property. I'll write some code of a brick that'll damage the player who clicks it if they're on a specific team as an example.
--put the click detector and the script in the part clickDetector = script.Parent.ClickDetector team = game.Teams["Insert Team Name Here"] clickDetector.OnClick:Connect(function(plr) if(plr.Team == team) then plr.Character.Humanoid.Health-=20 end end)
Some stuff may be correct like incorrect event names or smth since I haven't used roblox in a hot moment, but adapt that code to what you need.