|
| 11 Feb 2017 11:49 AM |
I'm trying to do this thing were if a player touches a brick, the player will die. But I'm trying to make it so if the players team color is the same color as the brick, the player doesn't die. I wrote something but it doesn't work. Can someone fix it up?
function onTouched(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then local plr = humanoid.Parent local name = plr.Name local playerinplayers = game.Players:FindFirstChild(name) if playerinplayers.TeamColor ~= script.Parent.BrickColor then humanoid.MaxHealth = 0 ---change number to what you want max health to be end end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 11 Feb 2017 11:51 AM |
local part = script.Parent
part.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and part.BrickColor ~= player.TeamColor then player.Character:BreakJoints() end end)
|
|
|
| Report Abuse |
|
|
|
| 11 Feb 2017 01:07 PM |
if I wanted to use that script with 'takedamage', is this correct:
Damage = script.Parent.Config.Damage.Value local part = script.Parent
part.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player and part.BrickColor ~= player.TeamColor then player.Character.Humanoid:TakeDamage(Damage) end end)
|
|
|
| Report Abuse |
|
|