I am trying to make a game pass to set a player's int value (not for leaderboard) for a game where players can make their own obby. But whenever I run the script, it gives me this error message:
18:57:50.780 - Unable to cast value to Object
18:57:50.781 - Stack Begin
18:57:50.781 - Script 'Workspace.SaveObbySizeScript', Line 7
18:57:50.782 - Stack End
This is the code:
local datastore = game:GetService("DataStoreService")
local ds = datastore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:connect(function(plr)
local obbySize = Instance.new("IntValue", plr)
obbySize.Name = "ObbySize"
if game:GetService("GamePassService"):PlayerHasPass(plr.UserId, 4478771) then
print("Success")
obbySize.Value = 2000
ds:SetAsync(plr.UserId, obbySize.Value)
else
obbySize.Value = ds:GetAsync(plr.UserId) or 300
ds:SetAsync(plr.UserId, obbySize.Value)
end
obbySize.Changed:connect(function()
ds:SetAsync(plr.UserId, obbySize.Value)
end)
end)

2 comments
PlayerHasPass() takes player as the first arugment, not userid
Now it says 18:18:26.113 - GamePassId '4478771' is not of type Game Pass. Please use MarketplaceService:PlayerOwnsAsset instead. But it is definitely a game pass.