Hello, so I’m working on admin gamepass. And the admin is bundle with the halo. but I have problem is on when people own the gamepass the admin doesn’t work also with the halo. Im kinda new at scripting. So here my script :
local id = 26003822
local admins = {}
local commands = {"/echo"}
local LockedGui = game.StarterGui.HaloGui.MainFrame.HaloHandler.InfernoHalo:WaitForChild("Locked")
function IsAdmin(player)
for _, v in pairs(admins) do
if v == player.Name then
return true
end
end
return false
end
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
if purchased and id == ido then
LockedGui.Visible = false
table.insert(admins, plr.Name)
end
end)
game.Players.PlayerAdded:Connect(function(player)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then
LockedGui.Visible = false
table.insert(admins, player.Name)
end
end)
game.Players.PlayerAdded:Connect(function(player)
if IsAdmin(player) then
player.Chatted:Connect(function(mag)
local split = mag:split(" ")
if split[1] == commands[1] then
local wordtoecho = split[2]
print(wordtoecho)
end
end)
end
end)
print(admins)
the lock gui mean is when the halo gui have lock gui. The halo doesn’t clone into player character
I can’t really tell what’s the issue but you might want to try debugging the script by adding multiple print() functions in all the segments so you can tell which segment didn’t work correctly.
Why is it necessary to have 2 PlayerAdded Events? You could just combine them into 1 entire function so that it can check for both Gamepass Users, and also checking for the Message you want to find
Also I believe your script isn’t working mostly because of these lines here:
You’re checking for the Player’s Instance in when calling that function, not the Player’s Name (They’re both different)
Also, you’re attempting to retrieve the StarterGui of the workspace, not the PlayerGui’s LockGui object
local ID = 26003822
local Admins = {}
local MPS = game:GetService("MarketplaceService")
local Commands = {"/echo"}
local function CheckMessage(Message)
local Split = Message:Split(" ")
print(Split)
if Split[1] == Commands[1] then
local WordToEcho = Split[2]
print(WordToEcho)
end
end
local function CheckPurchase(Plr, GamepassID, Completed)
local PlayerGui = Plr:WaitForChild("PlayerGui")
local LockedGui = PlayerGui:WaitForChild("HaloGui"):WaitForChild("MainFrame"):WaitForChild("HaloHandler"):WaitForChid("InfernoHalo"):WaitForChild("Locked") --Personally is a bit over excessive, I'd rather just check for a easier UIObject to set visible
if Completed and ID == GamepassID then
LockedGui.Visible = false
table.insert(Admins, Plr.Name)
Plr.Chatted:Connect(CheckMessage)
end
end
local function IsAdmin(Player)
for _, Plr in pairs(Admins) do
if Plr == Player.Name then
return true
end
end
return false
end
local function PlayerAdded(Player)
local PlayerGui = Plr:WaitForChild("PlayerGui")
local LockedGui = PlayerGui:WaitForChild("HaloGui"):WaitForChild("MainFrame"):WaitForChild("HaloHandler"):WaitForChid("InfernoHalo"):WaitForChild("Locked")
if IsAdmin(Player.Name) then
Player.Chatted:Connect(CheckMessage)
end
end)
game.Players.PlayerAdded:Connect(PlayerAdded)
MPS.PromptGamePassPurchaseFinished:Connect(CheckPurchase)
Not sure if this would work but I revised the script a bit