Can anyone help me this script ? Half script is right but access to team is incorrect :
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local TweenService = game:GetService("TweenService")
local door = script.Parent.Door
local trigger = script.Parent.Trigger
local SoundOpen = script.Parent.SoundOpen
local SoundClose = script.Parent.SoundClose
local goalClose = {CFrame = CFrame.new(-32.389, 3.595, -2.126) * CFrame.Angles(0, math.rad(180), 0)}
local goalOpen = {CFrame = CFrame.new(-34.693, 3.595, -0.063) * CFrame.Angles(0, math.rad(90), 0)}
local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(door, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(door, tweenInfo, goalClose)
local function isValidPlayer(player)
return player and player.Parent and player.Team == Teams["Police"]
end
local function openDoor(player)
if isValidPlayer(player) then
SoundOpen:Play()
tweenOpen:Play()
wait(2)
tweenClose:Play()
SoundClose:Play()
end
end
trigger.Touched:Connect(function(hit)
local character = hit.Parent
local player = Players:GetPlayerFromCharacter(character)
openDoor(player)
end)

1 comment
What is the reason for returning player and player.Parent?