I'm not sure if I put the loop on the wrong place or something, but I've tried everything and it just doesn't work... I don't have the gamepass and I went into the server side and changed my "XM" value to 2 which should be change back to 1, but it doesn't do that
wait(1)
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 111
game.Players.PlayerAdded:Connect(function(player)
while wait() do
local hasPass = false
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
player:WaitForChild("leaderstats")
player:FindFirstChild("Stats").XM.Value = 2
end
if hasPass == false then -- I've tried else and elseif but they don't work
player.Stats.XM.Value = 1
end
end
end)
