I want to achieve a script that checks if a membership has run out, the problem with this is that i get the error: attempt to compare nil and number
, i don’t know what causes this, i’ve already searched for this but none of the posts actually helped me with this problem.
Players.PlayerAdded:Connect(function(Player)
local MembershipData = MembershipDatastore:GetAsync(MembershipDataKey..Player.UserId)
if MembershipData then
while true do
wait(10)
if MembershipDataKey.EndsOn < os.time() then
local Success,ErrorMessage = pcall(function()
MembershipDatastore:RemoveAsync(MembershipDataKey..Player.UserId)
end)
if Success then
Player:LoadCharacter()
print("Membership removed from: "..Player.Name)
else
print("Error: "..ErrorMessage)
end
end
end
end
end)