You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I want my Gate to be exclusive to the Transit Authority team in my game. -
What is the issue?
I’m too crappy to figure out when I need to check what team the player is on. -
What solutions have you tried so far?
Well, I tried looking on the DevForum, but none of them fit my situation.
Here’s the script I tried:
local trigger = script.Parent
local gate = script.Parent.Parent.Gate
local buttonsound = script.Parent.Sound
moving = false
open = false
function onClick(player)
if player.Team.Name == "CTA" then
if open == false and moving == false then
buttonsound:Play()
moving = true
trigger.BrickColor = BrickColor.new("Bright yellow")
for i = 1, (gate.Size.Y * 10 + 1) do
wait()
gate.CFrame = gate.CFrame*CFrame.new(0, 0, -0.2)
end
moving = false
open = true
trigger.BrickColor = BrickColor.new("Bright red")
elseif open == true and moving == false then
buttonsound:Play()
moving = true
trigger.BrickColor = BrickColor.new("Bright yellow")
for i = 1, (gate.Size.Y * 10 + 1) do
wait()
gate.CFrame = gate.CFrame*CFrame.new(0, 0, 0.2)
end
moving = false
open = false
trigger.BrickColor = BrickColor.new("Bright green")
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick(player))
end
And here’s the base script:
local trigger = script.Parent
local gate = script.Parent.Parent.Gate
local buttonsound = script.Parent.Sound
moving = false
open = false
function onClick(player)
if open == false and moving == false then
buttonsound:Play()
moving = true
trigger.BrickColor = BrickColor.new("Bright yellow")
for i = 1, (gate.Size.Y * 10 + 1) do
wait()
gate.CFrame = gate.CFrame*CFrame.new(0, 0, -0.2)
end
moving = false
open = true
trigger.BrickColor = BrickColor.new("Bright red")
elseif open == true and moving == false then
buttonsound:Play()
moving = true
trigger.BrickColor = BrickColor.new("Bright yellow")
for i = 1, (gate.Size.Y * 10 + 1) do
wait()
gate.CFrame = gate.CFrame*CFrame.new(0, 0, 0.2)
end
moving = false
open = false
trigger.BrickColor = BrickColor.new("Bright green")
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
And here is how it looks in Workspace.
I honestly just want to know where I need to check the player’s team.
Thanks.