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

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

Asked by
Zikelah 20
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)
0
ok Zikelah 20 — 4y
Ad
Log in to vote
0
Answered by
Zikelah 20
4 years ago
Edited 4 years ago
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)

Answer this question