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

How to detect a players team in a if statement?

Asked by 3 years ago

I have a door script that works completely fine until I had an if statement on which team the player is in. I've tried and I feel like this would make sense but it doesn't work.

local ts = game:GetService("TweenService")
local tweeninfo2 = TweenInfo.new(3.75)
local goalA = {}
goalA.Position = Vector3.new(-67.107, 14.625, -17.316)
local tweenA = ts:Create(script.Parent, tweeninfo2, goalA)
local goalB = {}
goalB.Position = Vector3.new(-67.107, 21.875, -17.316)
local tweenB = ts:Create(script.Parent,tweeninfo2, goalB)



local opened = false
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local Team = game:GetService("Teams")["Administrator"]
    if player.Team == Team then
        print(player.Name)
        print(player.Name .. " is an Administrator.")
        opened = true
        script.Parent["Sliding door 2"].Playing = true
        tweenB:Play()
        wait(7)
        script.Parent["Sliding door 2"].Playing = true
        tweenA:Play()
        wait(1)
        opened = false
    end
end)

1 answer

Log in to vote
1
Answered by
TGazza 1336 Moderation Voter
3 years ago

Might be obvious but try this:

local ts = game:GetService("TweenService")
local tweeninfo2 = TweenInfo.new(3.75)
local goalA = {}
goalA.Position = Vector3.new(-67.107, 14.625, -17.316)
local tweenA = ts:Create(script.Parent, tweeninfo2, goalA)
local goalB = {}
goalB.Position = Vector3.new(-67.107, 21.875, -17.316)
local tweenB = ts:Create(script.Parent,tweeninfo2, goalB)

local opened = false
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local Team = game:GetService("Teams")
    local Admin_Team = Team:FindFirstChild("Administrator")
    if(Admin_Team == nil) then
    warn("warning!: there is no team named Administrator in the Teams Service! \n ADMINS WHERE ARE YOUS!!!!!")

    end
    if player.Team == Admin_Team then
        print(player.Name)
        print(player.Name .." is an Administrator.")
        opened = true
        script.Parent["Sliding door 2"].Playing = true
        tweenB:Play()
        wait(7)
        script.Parent["Sliding door 2"].Playing = true
        tweenA:Play()
        wait(1)
        opened = false
    end
end)
0
Its still not working. :/ Aeroporia 37 — 3y
0
I added a print thing after the function above local Team. To print the players name and it does print it but it doesn't do anything in the if statement Aeroporia 37 — 3y
0
Alright for some reason it wasn't working on ROBLOX Studio but it works in ROBLOX player so thank you! Aeroporia 37 — 3y
Ad

Answer this question