local isOn = true
local player = game.Players.LocalPlayer
function on()
isOn = true
script.Parent.Transparency = 0
script.Parent.CanCollide = true
end
function off()
isOn = false
script.Parent.Transparency = 0.8
script.Parent.CanCollide = false
end
function onClicked()
if player.Team == game.Teams["Emergency Response Team"] or player.Team == game.Teams["Officer"] or player.Team == game.Teams["High-Command"] then
if isOn == true then off() else on() end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
on()
The “Error” is attempt to index nil with “Team”
How can I define Team? Thanks for ur Help
If it’s a local script, it has to be in a place that replicates stuff to the client. Such as starterplayerscripts. And then you will need to change script.Parent.ClickDetector to wherever the part in the workspace is.
local isOn = true
local player = game.Players.LocalPlayer
local team = game:GetService("Teams")
function on()
isOn = true
script.Parent.Door.Transparency = 0
script.Parent.Door.CanCollide = true
end
function off()
isOn = false
script.Parent.Door.Transparency = 0.8
script.Parent.Door.CanCollide = false
end
function onClicked()
if player.TeamColor == BrickColor.new('Black') or player.TeamColor == BrickColor.new('Br. yellowish orange') or player.TeamColor == BrickColor.new('Navy blue') then
if isOn == true then off() else on() end
end
end
script.Parent.Butt.ClickDetector.MouseClick:connect(onClicked)
on()
That is now the script and the door (SolDoor) But if I test and set my team to Officer ( Navy Blue) and click the Button (Butt9 the door doesnt open can u pls help me? (Im not a scripter)
local isOn = true
local player = game.Players.LocalPlayer
local team = game:GetService("Teams")
function on()
isOn = true
script.Parent.Door.Transparency = 0
script.Parent.Door.CanCollide = true
end
function off()
isOn = false
script.Parent.Door.Transparency = 0.8
script.Parent.Door.CanCollide = false
end
game.Workspace.DoorSol.Butt.ClickDetector.MouseClick:Connect(function(onClicked)
if player.TeamColor == BrickColor.new('Black') or player.TeamColor == BrickColor.new('Br. yellowish orange') or player.TeamColor == BrickColor.new('Navy blue') then
if isOn == true then off() else on() end
end
end)
game.Workspace.DoorSol.Butt.ClickDetector.MouseClick:Connect(function(player) Sorry, it should be like that, with the player as the parameter, and as long as its in starterplayerscripts it should work
function on()
isOn = true
for _, v in pairs(game.Workspace.DoorSol:GetChildren()) do
if v.Name == "Door" then
v.Transparency = .8
v.CanCollide = false
end
end
end
It only works on 1 door. What can i do that it works on more than one door (not at the same time) I mean that i can open a door but i cant open an other door