So, this one is a bit of a tall order, but I have no idea how to proceed from here. It's way out of my element.
My team and I have been developing a morph system GUI. It uses a folder of 3D morphs and puts them in a list. If the system deems you to have access to the morph, it creates a button for it. You click on the buttons, it brings up a spinning model of them on the side of the screen, and then you can click spawn to enter into the world with it on.
It works perfectly fine, but there's something we don't know how to add to it. Certain morphs need to be locked behind a game pass, but all of them need to be available to my admins.
The thing is, the way that this is set up, it can have permissions based on whether or not somebody is a group. Right now it always returns true. If they're in the group, they can have extra morphs or something. I don't really understand that part. From what I can understand, as long as it returns true, it should be available to use. I'm just not sure how to substitute those conditions for the ones I need.
Here's the full script just in case it helps, but I pinpointed which area of it that I need help to edit.
repeat wait() until game.Players.LocalPlayer
repeat wait() until game.Players.LocalPlayer.Character
---[]---// Variables //---[]---
local plr = game.Players.LocalPlayer
local character = plr.Character
local camera = game.Workspace.Camera
local contentprovider = game:GetService("ContentProvider")
local model = game.ReplicatedStorage.dum:Clone()
local dummy = model.Dummy
---[]---// Folders //---[]---
local Armors = game.ReplicatedStorage:WaitForChild("Armors")
---[]---// Gui //---[]---
local Gui = script.Parent
local Selections = Gui:WaitForChild("Selections")
local Loading = Gui:WaitForChild("Loading")
local Morph
---[]---// Modules //---[]---
local weld = require(script:WaitForChild("Weld"))
---[]---// Functions //---[]---
local function characterCreator ()
--// Camera Create
local cam = Instance.new("Camera")
cam.CFrame = model.cam.CFrame
cam.Parent = Selections.Character
--// Model Create
model.Parent = Selections.Character
Selections.Character.CurrentCamera = cam
--// RotateModel
game:GetService("RunService").RenderStepped:connect(function()
dummy:SetPrimaryPartCFrame(dummy.Torso.CFrame * CFrame.Angles(0,.01,0))
wait(0.1)
end)
end
local function CheckID(Group,ID,RankLock)
if Group == 0 then return true else
if RankLock and plr:GetRankInGroup(Group) == ID then return true else return false end
if not RankLock and plr:GetRankInGroup(Group) >= ID then return true else return false end
end
end
local function CreateSelection ()
local p = 0
for i,v in pairs(game.ReplicatedStorage.Armors:GetChildren()) do
if CheckID(v.Config.GroupID.Value,v.Config.Rank.Id.Value,v.Config.Rank.Value) == false then return end
local Button = Instance.new("TextButton")
--// Button Modif
Button.TextColor3 = Color3.fromRGB(255,255,255)
Button.TextScaled = true
Button.TextSize = 40
Button.TextXAlignment = "Left"
Button.Font = Enum.Font.GothamBold
Button.BackgroundTransparency = 0.8
Button.Position = UDim2.new(0,0,0,55 * p)
Button.Size = UDim2.new(1,0,0.06,0)
Selections.SF.CanvasSize = UDim2.new(0,0,0,55 * p)
p = p + 1
--// Button Spawn
Button.Parent = Selections.SF
Button.Name = v.Name
--// Text sub
for i = 1,v.Config.Title.Value:len() do
print(v.Config.Title.Value:len())
Button.Text = v.Config.Title.Value:sub(1, i)
wait(0/v.Config.Title.Value:len())
end
--// Events
Button.MouseEnter:connect(function()
local sf = Selections.SF:GetChildren()
for i = 1,#sf do
sf[i].Size = UDim2.new(0.5,0,0,55)
end
Button:TweenSize(UDim2.new(1,0,0,50),"InOut","Linear",0.1)
end)
Button.MouseButton1Click:connect(function()
weld.RemoveStuff(dummy)
weld.CreateStuff(v,dummy)
Morph = v
local sf = Selections.SF:GetChildren()
for i = 1,#sf do
sf[i].TextColor3 = Color3.fromRGB(255,255,255)
end
Button.TextColor3 = Color3.fromRGB(0,0,0)
for i = 1,v.Config.Title.Value:len() do
print(v.Config.Title.Value:len())
Selections.Character.MorphName.Text = v.Config.Title.Value:sub(1, i)
wait(0/v.Config.Title.Value:len())
end
end)
end
end
local function cammover (part)
camera.CameraType = Enum.CameraType.Scriptable
local tweenService = game:GetService("TweenService")
local tween = tweenService:Create(camera,TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{CFrame = part,Focus = camera.CFrame})
tween:Play()
end
local function LoadingAssets ()
local can = true
local assets = contentprovider.RequestQueueSize
while wait() and can do
if contentprovider.RequestQueueSize == 0 then
Loading:TweenSize(UDim2.new(0.3,0,1,0),"InOut","Linear",0.5)
wait(.5)
Loading.Visible = false
Selections.Visible = true
cammover (workspace.Cam.cam2.CFrame)
characterCreator ()
CreateSelection ()
can = false
return
end
Loading.Visible = true
Loading.AssetsText.Text = assets - contentprovider.RequestQueueSize .. " / " .. assets
Loading.Rot.Rotation = Loading.Rot.Rotation + 0.01
end
end
---[]---// Listings Events //---[]---
LoadingAssets ()
Selections.Deploy.MouseButton1Click:connect(function()
if Morph:FindFirstChild("Helmet") then game.ReplicatedStorage.Weld:FireServer(Morph,"Helmet","Head") end
if Morph:FindFirstChild("Chest") then game.ReplicatedStorage.Weld:FireServer(Morph,"Chest","Torso") end
if Morph:FindFirstChild("Arm1") then game.ReplicatedStorage.Weld:FireServer(Morph,"Arm1","Left Arm") end
if Morph:FindFirstChild("Arm2") then game.ReplicatedStorage.Weld:FireServer(Morph,"Arm2","Right Arm")end
if Morph:FindFirstChild("Leg1") then game.ReplicatedStorage.Weld:FireServer(Morph,"Leg1","Left Leg")end
if Morph:FindFirstChild("Leg2") then game.ReplicatedStorage.Weld:FireServer(Morph,"Leg2","Right Leg")end
Selections.Visible = false
cammover (character.Head.CFrame * CFrame.new(0,0.7,4))
camera.CameraType = Enum.CameraType.Custom
end)
So, that's all there if you need it, but here's the specific area of interest in it.
local function CheckID(Group,ID,RankLock)
if Group == 0 then return true else
if RankLock and plr:GetRankInGroup(Group) == ID then return true else return false end
if not RankLock and plr:GetRankInGroup(Group) >= ID then return true else return false end
end
end
local function CreateSelection ()
local p = 0
for i,v in pairs(game.ReplicatedStorage.Armors:GetChildren()) do
if CheckID(v.Config.GroupID.Value,v.Config.Rank.Id.Value,v.Config.Rank.Value) == false then return end
local Button = Instance.new("TextButton")
Each morph is saved as a model. It has a model called "Helmet" which is just the morph itself, a pair of pants and shirts (because we just didn't bother to edit that out of the script), and a folder called "Config". Inside Config are three values. They're "GroupID", "Title", and "Rank". Inside Rank is a number value named "Id". If I'm being honest, I have no idea how they interact with each other. I haven't had to manage code like this before.
All of those values are set to zero, and I'm not sure which one or ones determine if a button is created or not.
As far as I can tell, as long as it returns true, the morph's button is created. The current script looks to see if the player is a part of a group to give permissions to the blocked morphs. That's the best synopsis I can give.
Like I said above, instead of checking for if the player is in a group, I need for it to check whether or not the player has a game pass. If they do, then it should return true and make the button for the morph. But, the tricky part is that I also need it to be available to specific players by checking their usernames. I'm sure it could be done by reading one of the values inside the morph and then checking for the corresponding gamepass, if the code is other than zero. Then something along the lines of "else if player.name = {'adminperson',} then return true". I'm just not nearly experienced enough to know how to do all that and have it work.
Anybody know how we could get it to work like this? Sorry that this is really long, but it's necessary to complete and update that my team and I have been working on for over two months now. If you need clarification or anything, I'd be more than happy to supply you with whatever you need. Thanks in advance to anybody able to help.
