Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

Formatted codes in codeblock.

1 answer

✓ Accepted answer

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())

This discussion is preserved as it was. New answers, comments, and votes are closed.