Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
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

Log in to vote
0
Answered by 3 years ago

https://developer.roblox.com/en-us/api-reference/property/Player/Team

You could do an if statement like this

if Player.Team == "YourTeamName" then

    -- Your code

end
Ad
Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

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)
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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)

0
This sadly does not work fdfdfdfdfHAU 2 — 3y
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). chess123mate 5873 — 3y
0
idk worked fine for me Stylxus 1 — 3y

Answer this question