Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a part that damages a player in a specific team?

Asked by 3 years ago

How would I make a script in a part that damages a player on a certain team?

2 answers

Log in to vote
0
Answered by 3 years ago

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

01local DamagePerTouch = 25 -- How much damage per touch will it deal
02 
03local CooldownPerTouch = 0.5 -- How much time in seconds to be able to damage again
04 
05local TeamName = "Team Name Here" -- The exact name of the team
06 
07 
08local part = script.Parent
09local Team = game.Teams[TeamName]
10active = true
11 
12function OnTouch(hit)
13    local plr = hit.Parent
14    if plr:FindFirstChild("Humanoid") then
15        local user = game.Players:GetPlayerFromCharacter(plr)
View all 26 lines...
Ad
Log in to vote
1
Answered by 3 years ago

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.

1--put the click detector and the script in the part
2clickDetector = script.Parent.ClickDetector
3team = game.Teams["Insert Team Name Here"]
4clickDetector.OnClick:Connect(function(plr)
5    if(plr.Team == team) then
6        plr.Character.Humanoid.Health-=20
7    end
8end)

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.

0
Sorry for not being too clear, I meant that when touched a player on a specific team, they will get damaged. Mystical_Un1verse 9 — 3y

Answer this question