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

How would I make this a player instead of a team?

Asked by 5 years ago
Edited 5 years ago

I want to know how I would properly make it so it only lets a player in not a team.

local team = game.Teams.Blue

local door = script.Parent

door.Touched:connect(function(hit)
 local humanoid = hit.Parent:FindFirstChild("Humanoid")
 if humanoid then
  local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  if plr.Team == team then
   door.CanCollide = false
   door.Transparency = .5
   wait(1)
   door.CanCollide = true
   door.Transparency = 0
  else
   humanoid.Health = 0
  end
 end
end)

0
Formatted codes in codeblock. User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

Simple. Instead of checking if the player's team equals something, check their name or their userid: if plr.Name == "GarrettlovesGTA" then.

You would use it in your code like this:

local door = script.Parent

door.Touched:Connect(function(hit)
 local humanoid = hit.Parent:FindFirstChild("Humanoid")
 if humanoid then
  local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  if plr.Name == "GarrettlovesGTA" then --here, see?
   door.CanCollide = false
   door.Transparency = .5
   wait(1)
   door.CanCollide = true
   door.Transparency = 0
  else
   humanoid.Health = 0
  end
 end
end)

(Btw use :Connect() rather than :connect())

Ad

Answer this question