It almost worked but I set the gamepass and badgeid to random and the script is still active when I test it
Huh if this doesnt work then to be honest I have no idea what to do.
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local MarketplaceService = game:GetService("MarketplaceService")
local badgeid = script.Parent.Parent:WaitForChild("BadgeID").Value
local gamepassid = script.Parent.Parent:WaitForChild("GamepassID").Value
local function playerGates(player)
local Character = player.Character
local HasBadge, BadgeResult = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, badgeid)
end)
local HasGamepass, GamepassResult = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassid)
end)
if not HasBadge or not HasGamepass then
local gateScript = game.Workspace:FindFirstChild("Gate2") and game.Workspace.Gate2:FindFirstChild("TouchGateScript")
if gateScript then
gateScript.Enabled = false
end
end
end
local event = game.ReplicatedStorage.JoinEvent
event.OnServerEvent:Connect(function(player)
playerGates(player)
end)
There might be an issue with how you handle the result from pcall
. Other then that I have no clue.
I tested this in game and it still does not work. Do you think it is the id?
It could, but all I can think of is ensuring that the badge and the game pass ID are the same as the IDs you are using in-game.
You were checking if the pcalls succeeded, not the result of the pcalls.
Here is the script so far, I changed the gamepassid and badgeid so you can see it. But still does not work.
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local MarketplaceService = game:GetService("MarketplaceService")
local badgeid = 0
local gamepassid = 0
local function playerGates(player)
local Character = player.Character
local HasBadge, BadgeResult = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, badgeid)
end)
local HasGamepass, GamepassResult = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassid)
end)
if not HasBadge or not HasGamepass then
local gateScript = game.Workspace:FindFirstChild("Gate2") and game.Workspace.Gate2:FindFirstChild("TouchGateScript")
if gateScript then
gateScript.Enabled = false
end
end
end
local event = game.ReplicatedStorage.JoinEvent
event.OnServerEvent:Connect(function(player)
playerGates(player)
end)
Ohh, ensure that the badge and the game pass ID are the same as the IDs you are using in-game. I that’s your problem.
So I will just use an alt account to test it?
You’re checking if the pcalls succeeded, try switching it around to the result of the pcalls instead.
Yeah it still does not work. I used 2 accounts at the same time, 1 that does not have gamepass and badge and 1 that has both of it. They both have enabled scripts just like before when I switched the gamepassID and BadgeID to 0
What do you mean by switching it around?
If you scroll up a bit, I sent a modified version of the original code.
1 Worked. The badgeID works alone but not the gamepassID
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")
local MarketplaceService = game:GetService("MarketplaceService")
local badgeid = 155440073325875
local gamepassid = 1014470325
local function playerGates(player)
local Character = player.Character
local Success, HasBadge = pcall(function()
return BadgeService:UserHasBadgeAsync(player.UserId, badgeid)
end)
local Success2, HasGamepass = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassid)
end)
if not HasBadge or not HasGamepass then
local gateScript = game.Workspace:FindFirstChild("Gate2") and game.Workspace.Gate2:FindFirstChild("TouchGateScript")
if gateScript then
gateScript.Enabled = false
end
end
end
local event = game.ReplicatedStorage.JoinEvent
event.OnServerEvent:Connect(function(player)
playerGates(player)
end)
Yeah just check if they have the gamepass aswell. Here’s the modified code to check for the gamepass.
The script still does not work. It only does the badge and not the gamepass. I have the gamepass id in the game and do not have the badge in the game.
Whoops yeah my bad, give me a minute to edit the original code. I made a typo lol.
Alright updated it, try again.
The gamepass still does not work.
The 30 is the timer to teleport the players into the server and it does not go down when I have the gamepass when it should be
That’s odd, my reproduction of the code seems to be working fine. When I don’t own either, it prints in the stop statement. When I own one, it does not. Same as owning both. Have you tried checking your countdown script?