Sigh, greetings once again, Scripting Helpers community. I'm trying to make a script that constantly checks if a player bought a Game Pass, and if the player does, one of their stats will be changed. But, uh, it's just not working. Sorry if I'm being a huge moron, I never worked with Game Passes and developer products before...
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) while wait() do if game:GetService("GamePassService"):PlayerHasPass(game.Players.LocalPlayer, 466868120) then game.Players.LocalPlayer.stats.Venustoise.Value = 1 end end end) end)
The error is on line 4, as the output says. 22:38:02.477 - Not a valid Player
Please give me a hand with this, I tried so many times to make this work but I just couldn't.
Roblox wiki always has amazing answers if you take the time to look it up. Here is what you can get from the wiki. This checks when a player is added if he/she has the gamepass. I edited it so that it would change the value for your stats.
EDIT: Because I can't read, changed the script to constantly check if a player has the pass. Still using roblox wiki as a baseline reference though :)
local passId = 466868120 -- change this to your game pass ID. local person = game.Players.LocalPlayer function isAuthenticated(player) -- checks to see if the player owns your pass return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId) end function CheckPass() if isAuthenticated(person) then print(person.Name .. " has bought the game pass with id " .. passId) game.Players.LocalPlayer.stats.Venustoise.Value = 1 end end while wait(1) do -- change wait time to whatever you want CheckPass() end