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

How do I make it so that my button only works for a certain team?

Asked by 5 years ago

As it says for the title.

Clicker = script.Parent
Pass = script.Parent.Parent.Pass
Click = script.Parent.Parent.Click
Door1 = script.Parent.Parent.Door1 
Door2 = script.Parent.Parent.Door2 
Door3 = script.Parent.Parent.Door3 
Door4 = script.Parent.Parent.Door4 

function onClicked()
    if Click.Value == true then
    if Pass.Value == true then
                 script.Parent.Sound:Play()
        Click.Value = false
        for i = 1, 36 do
        Door4.CFrame = Door4.CFrame * CFrame.new(0,0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, -0.043)
        Door3.CFrame = Door3.CFrame * CFrame.new(0,0.1,0)
        Door2.CFrame = Door2.CFrame * CFrame.new(0,0.1,0)
        Door1.CFrame = Door1.CFrame * CFrame.new(0,0.1,0)
        wait(0.1)
        end
        for i = 1, 36 do
        Door3.CFrame = Door3.CFrame * CFrame.new(0,0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, -0.043)
        Door2.CFrame = Door2.CFrame * CFrame.new(0,0.1,0)
        Door1.CFrame = Door1.CFrame * CFrame.new(0,0.1,0)
        Door4.CFrame = Door4.CFrame * CFrame.new(0,0.1,0)
        wait(0.1)
        end
        for i = 1, 36 do
        Door2.CFrame = Door2.CFrame * CFrame.new(0,0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, -0.043)
        Door1.CFrame = Door1.CFrame * CFrame.new(0,0.1,0)
        Door4.CFrame = Door4.CFrame * CFrame.new(0,0.1,0)
        Door3.CFrame = Door3.CFrame * CFrame.new(0,0.1,0)
        wait(0.1)
        end
        for i = 1, 36 do
        Door1.CFrame = Door1.CFrame * CFrame.new(0,0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, -0.043)
        Door4.CFrame = Door4.CFrame * CFrame.new(0,0.1,0)
        Door3.CFrame = Door3.CFrame * CFrame.new(0,0.1,0)
        Door2.CFrame = Door2.CFrame * CFrame.new(0,0.1,0)
        wait(0.1)
        end
        Click.Value = true
        Pass.Value = false
    else
                 script.Parent.Sound:Play()
        Click.Value = false
        for i = 1, 36 do
        Door1.CFrame = Door1.CFrame * CFrame.new(0,-0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, 0.043)
        Door4.CFrame = Door4.CFrame * CFrame.new(0,-0.1,0)
        Door3.CFrame = Door3.CFrame * CFrame.new(0,-0.1,0)
        Door2.CFrame = Door2.CFrame * CFrame.new(0,-0.1,0)
        wait(0.1)
        end
        for i = 1, 36 do
        Door2.CFrame = Door2.CFrame * CFrame.new(0,-0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, 0.043)
        Door1.CFrame = Door1.CFrame * CFrame.new(0,-0.1,0)
        Door4.CFrame = Door4.CFrame * CFrame.new(0,-0.1,0)
        Door3.CFrame = Door3.CFrame * CFrame.new(0,-0.1,0)
        wait(0.1)
        end
        for i = 1, 36 do
        Door3.CFrame = Door3.CFrame * CFrame.new(0,-0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, 0.043)
        Door2.CFrame = Door2.CFrame * CFrame.new(0,-0.1,0)
        Door1.CFrame = Door1.CFrame * CFrame.new(0,-0.1,0)
        Door4.CFrame = Door4.CFrame * CFrame.new(0,-0.1,0)
        wait(0.1)
        end
        for i = 1, 36 do
        Door4.CFrame = Door4.CFrame * CFrame.new(0,-0.1,0) * CFrame.fromEulerAnglesXYZ(0, 0, 0.043)
        Door3.CFrame = Door3.CFrame * CFrame.new(0,-0.1,0)
        Door2.CFrame = Door2.CFrame * CFrame.new(0,-0.1,0)
        Door1.CFrame = Door1.CFrame * CFrame.new(0,-0.1,0)
        wait(0.1)
        end
        Click.Value = true
        Pass.Value = true
    end
    end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)


while wait() do
if Pass.Value == true then
script.Parent.BrickColor = BrickColor.new(37)
else
script.Parent.BrickColor = BrickColor.new(21)
end
end



1
One simple if statement after they click to check if player is on team. The players team info should be on their Player I believe not character TheEpicObbyCreator 32 — 5y
0
On a MouseClick event, the first parameter is the player who clicked. You need to get the player who clicked. All players have a player.Team value, so you need to have the script check whether the player.Team == the team that you want to access the button. Extraordinarius -5 — 5y

Answer this question