Hi fellow coders! I am trying to make a code for gamepass only team. I put the script in a remote event and everything works in roblox studio but when i play the game in roblox it doesnt work. I applied edits published it etc but still and issue. Is this problem with my code or do I need to activate something like a setting. Anyways here is my code below:
script.Parent.OnServerEvent:Connect(function(player)
local GamepassId = "23857004"
local MarketplaceService= game:GetService("MarketplaceService")
local OwnsGamePass = false
print("beforeifstatement")
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
print("afterifstatement")
OwnsGamePass = true
print("insidefunction")
if OwnsGamePass == true then
player.Team = game.Teams.Security
local hum = player.Character:FindFirstChild("Humanoid")
hum.Health = 0
end
end
end)
