Hi everyone. I have a door in my game that I want to be transparent and can collide false IF you are on a certain team. If your not on the team the door is not transparent and the can collide is true.
I am trying to accomplish this by putting a local script in starter player scripts. The script is below but it does not seem to do anything. haha
Anyone have any ideas?
local player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")
local team = Teams["Team1"]
if player.Team == team then
game.Workspace.worldobjects.team1door.CanCollide = false
game.Workspace.worldobjects.team1door.Transparency = 1
end
``
local player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")
local team = Teams["Team1"]
repeat
wait()
until team ~= nil
print(team)
if player.Team == team then
game.Workspace.worldobjects.team1door.CanCollide = false
game.Workspace.worldobjects.team1door.Transparency = 1
end
local player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")
local team = Teams["Team1"]
while task.wait() do
if player.Team ~= nil then
game.Workspace.worldobjects.team1door.CanCollide = false
game.Workspace.worldobjects.team1door.Transparency = 1
break
end
end
local player = game.Players.LocalPlayer;
local Teams = game:GetService("Teams");
local team = Teams.Team1;
player:GetPropertyChangedSignal("Team"):Connect(function()
if player.Team == team then
game.Workspace.worldobjects.team1door.CanCollide = false;
game.Workspace.worldobjects.team1door.Transparency = 1;
end
end)
that actually works, but my idea is flawed. Once you play on team 1 the door remains open forever, even if you switch to team 2 or team 3. How would I make the door not transparent if your not on team 1?
local player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")
player:GetPropertyChangedSignal("Team"):Connect(function()
for i,v in pairs(game.Teams:GetDescendants()) do
if player.Team ~= v then
game.Workspace.worldobjects["team"..i.."door"].CanCollide = true;
game.Workspace.worldobjects["team"..i.."door"].Transparency = 0;
else
game.Workspace.worldobjects["team"..i.."door"].CanCollide = false;
game.Workspace.worldobjects["team"..i.."door"].Transparency = 1;
end
end
end)
actually ill just post my idea before I go to bed. I just made the door kill the other team if they touch it. It works and it is a lot simpler. But it still gives an error.
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local Teams = game:GetService("Teams")
local team = Teams["team1"]
if player.Team ~= team then
character.Humanoid.Health = 0
end
end)
The error is on line six. If you pass through the door as team1 the door does not kill you but it does give this error. 04:53:07.088 Workspace.worldobjects.teamdoor.Script:6: attempt to index nil with ‘Team’ - Server - Script:6
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player and player.Team ~= nil then
if player.Team.Name ~= "team1" then
character.Humanoid.Health = 0
end
end
end)