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

Hi i have an E to open script but dont know how to make it only for a certain team to open?

local Hinge = script.Parent.PrimaryPart
local opened = false

local Promt = script.Parent:WaitForChild("ProximityPrompt")

function OpenDoor()
	if opened == false then
		opened = true
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
			wait()
		end
	else
		opened = false
		for i = 1, 21 do
			script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
			wait()
		end
	end
end
Promt.Triggered:Connect(function(Players)
	OpenDoor()
end)
script.Parent.Door1.ProxomityPrompt.Triggered:Connect(OpenDoor)

This is the script How can i make it only for a certain team

3 answers

The way I have done this is by checking the player's team value against a team instance:

local Hinge = script.Parent.PrimaryPart
local opened = false

local Promt = script.Parent:WaitForChild("ProximityPrompt")

function OpenDoor(player)
    if not player.Team == game.Teams.YOUR_TEAM_NAME_HERE then return end -- Change YOUR_TEAM_NAME_HERE to your team name
    if opened == false then
        opened = true
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
            wait()
        end
    else
        opened = false
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
            wait()
        end
    end
end
Promt.Triggered:Connect(function(Players)
    OpenDoor()
end)
script.Parent.Door1.ProxomityPrompt.Triggered:Connect(OpenDoor)
local Hinge = script.Parent.PrimaryPart
local opened = false

local Promt = script.Parent:WaitForChild("ProximityPrompt")

function OpenDoor(player)
    if opened == false then
        if not player.TeamColor == "ColorOfTeam" then
            return
        end
        opened = true
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
            wait()
        end
    else
        if not player.TeamColor == "ColorOfTeam" then
            return
        end
        opened = false
        for i = 1, 21 do
            script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0))
            wait()
        end
    end
end
Promt.Triggered:Connect(function(Players)
    OpenDoor()
end)
script.Parent.Door1.ProxomityPrompt.Triggered:Connect(OpenDoor)

3 comments

0

This sadly does not work

0

Try player.Team.Name == "NameOfTeam" -- TeamColor requires a (I think) BrickColor object, not a string, so the Name is easier to compare. Also, it'd be better to do that if statement once at the beginning of the OpenDoor function (instead of having two copies of it throughout the function unnecessarily).

0

idk worked fine for me

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