0% found this document useful (0 votes)
8 views4 pages

Message

The script manages door interactions in a game, checking player permissions based on gamepass ownership and group rank. It utilizes TweenService for smooth door animations and handles player entry and exit events to control door accessibility. Notifications are sent to players who lack the necessary permissions to access certain doors.

Uploaded by

luckass729
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Message

The script manages door interactions in a game, checking player permissions based on gamepass ownership and group rank. It utilizes TweenService for smooth door animations and handles player entry and exit events to control door accessibility. Notifications are sent to players who lack the necessary permissions to access certain doors.

Uploaded by

luckass729
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

--// Services

local Players = game:GetService("Players")


local ReplicatedStorageService = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

--// Instances
local Player = Players.LocalPlayer
local Classes = ReplicatedStorageService.Classes

--// Modules
local NotificationHandler = require(Classes.NotificationHandler)
local ZoneHandler = require(Classes.ZoneHandler)
local GroupsInformation = require(Classes.GroupsInformation)

--// Variables
local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)
local Tween = nil
local SafeGamepass = ReplicatedStorageService.Functions.SafeCheckGamepass

local VerifyVip = false

local PortasPermissions = {

["Gamepass"] = {

"Porta dos Militares";


"Porta da Grade";

};

--// Functions
function ConvertStringToCFrame(str: string)

local StringSplit = string.split(str, "|")

return CFrame.new(string.split(StringSplit[1], ",")[1],


string.split(StringSplit[1], ",")[2], string.split(StringSplit[1], ",")[3]),
CFrame.Angles(math.rad(string.split(StringSplit[2], ",")[1]),
math.rad(string.split(StringSplit[2], ",")[2]),
math.rad(string.split(StringSplit[2], ",")[3]))

end

--// Code

local Gamepass_Data = SafeGamepass:InvokeServer(Player)

for _, Door: Model in workspace.DoorsFolder:GetChildren() do

if Door:IsA("Model") and Door.Name:match("Porta") and Door.Name ~= "Porta do


Bunker" then

local Zone = ZoneHandler.new(Door:WaitForChild("Zona"))

Zone.localPlayerEntered:Connect(function(player: Player)

if table.find(PortasPermissions["Gamepass"], Door.Name) then


VerifyVip = Gamepass_Data["VIP"]

end

if not VerifyVip and


player:GetRankInGroup(Door:GetAttribute("Grupo")) < Door:GetAttribute("Rank") then

NotificationHandler:SendNotificationByClient({

Title = "Porta",
Text = "Você não tem permissão!",
Duration = 3,

})

return

end

if not Door:GetAttribute("Dupla") then

Door.Porta.CanCollide = false

local CFrameValue, CFrameAngles =


ConvertStringToCFrame(Door.Hinge:GetAttribute("Aberto"))

local Tween = TweenService:Create(Door.Hinge, TweenInfo,


{ CFrame = CFrameValue * CFrameAngles })
Tween:Play()
Tween.Completed:Wait()

Door.Hinge.CFrame = CFrameValue * CFrameAngles

else

for _, SubDoor: Model in Door:GetChildren() do

if SubDoor:IsA("Model") and
SubDoor.Name:match("Porta") then

task.spawn(function()

SubDoor.Porta.CanCollide = false

local CFrameValue, CFrameAngles =


ConvertStringToCFrame(SubDoor.Hinge:GetAttribute("Aberto"))

local Tween =
TweenService:Create(SubDoor.Hinge, TweenInfo, { CFrame = CFrameValue * CFrameAngles
})
Tween:Play()
Tween.Completed:Wait()

SubDoor.Hinge.CFrame = CFrameValue *
CFrameAngles
end)

end

end

end

end)

Zone.localPlayerExited:Connect(function(player: Player)

if not VerifyVip and


player:GetRankInGroup(Door:GetAttribute("Grupo")) < Door:GetAttribute("Rank") then

return

end

VerifyVip = nil

if not Door:GetAttribute("Dupla") then

Door.Porta.CanCollide = true

local CFrameValue, CFrameAngles =


ConvertStringToCFrame(Door.Hinge:GetAttribute("Fechado"))

local Tween = TweenService:Create(Door.Hinge, TweenInfo,


{ CFrame = CFrameValue * CFrameAngles })
Tween:Play()
Tween.Completed:Wait()

Door.Hinge.CFrame = CFrameValue * CFrameAngles

else

for _, SubDoor: Model in Door:GetChildren() do

if SubDoor:IsA("Model") and
SubDoor.Name:match("Porta") then

task.spawn(function()

SubDoor.Porta.CanCollide = true

local CFrameValue, CFrameAngles =


ConvertStringToCFrame(SubDoor.Hinge:GetAttribute("Fechado"))

local Tween =
TweenService:Create(SubDoor.Hinge, TweenInfo, { CFrame = CFrameValue * CFrameAngles
})
Tween:Play()
Tween.Completed:Wait()

SubDoor.Hinge.CFrame = CFrameValue *
CFrameAngles

end)
end

end

end

end)

end

end

You might also like