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

[SOLVED] How would I make a script that if the player is on a certain team the door will open?

I want to make a door where if the player is on a certain team the door will open. Things I've tried:

if hum and player.team = Police then

but the = is not allowed. Would i create a variable for that or is there a method for it?

2 answers

✓ Accepted answer

Try this:

script.Parent.Touched:connect(function(part)
	local hum = part.Parent:FindFirstChild("Humanoid") 
	local plr = game.Players:GetPlayerFromCharacter(part.Parent)
	if hum and plr.Team == "Police" then 
		script.Parent.Anchored = true 
		script.Parent.CanCollide = false 
		wait(1) 
		script.Parent.CanCollide = true 
	end
end)

1 comment

0

ok

local me = script.Parent.Parent
local Light = script.Parent.Parent.Light
local db = true
local sensor = script.Parent
local Window = script.Parent.Parent.Window
local player = game.Players.LocalPlayer
local CorrectMusic = 'rbxassetid//826129174'
local Police = game:GetService("Teams"):FindFirstChild("Police")

function MoveTheDoor(hit)
    print('Running')
    local hum = hit.Parent:FindFirstChild('Humanoid')
    print('1')
    if hum  and player.Backpack:FindFirstChild("Keycard")then
    print('2')
        if db then
            db = false
            Light.Color = Color3.fromRGB(0,255,0)
            me.Position = Vector3.new(26.225, 5.075, -23.4)
			Window.Position = Vector3.new(26.225, 6.475, -23.4)
            wait()
            wait(4)
            wait()
            me.Position = Vector3.new(15.875, 5.075, -24.301)
            Light.Color = Color3.fromRGB(255,0,0)
			Window.Position = Vector3.new(15.875, 6.475, -24.401)
            wait()
            wait(.5)
            db = true
	elseif hum and player.Team == "Police" then
	
        end
    end

end
sensor.Touched:Connect(MoveTheDoor)

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