I made a gamepass that gives the player 1500 points when joining but when i test it it stays at 500 points and doesn't give me a error or anything
local MarketplaceService = game:GetService("MarketplaceService") function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local score = Instance.new("IntValue") score.Name = "Points" score.Value = 500 score.Parent = stats stats.Parent = newPlayer if MarketplaceService:PlayerOwnsAsset(newPlayer, 15884145) then score.Value = 1500 end while true do wait(60) score.Value = score.Value + 15 end end game.Players.ChildAdded:connect(onPlayerEntered)
Try using MarketplaceService:UserOwnsGamePassAsync(playerUserId,gamePassId) instead. Also instead of childAdded use .PlayerAdded
You made a typo with game.Players.ChildAdded:conenct(onPlayerEntered)
It should be game.Players.ChildAdded:Connect(onPlayerEntered)
Hello, i haven't tested this code out, but everything should work fine :)
If there's any problems, please @ me and let me know if anything's wrong.
local MarketPlaceService = game:GetService("MarketplaceService") function onPlayerEntered(newPlayer) local stats = Instance.new("IntValue") stats.Name = "leaderstats" local score = Instance.new("IntValue") score.Name = "Points" score.Parent = stats stats.Parent = newPlayer local hasPass = false -- Creating a boolean to use for to check if the player owns the gamepass -- Wrapping this in a pcall isn't necessary, but if roblox's servers shutdown or something, then the script won't break. local success, errormessage = pcall(function() hasPass = MarketPlaceService:UserOwnsGamePassAsync(newPlayer.UserId, 15884145) -- This essentially is setting this boolean to false or true depending on if the player has the gamepass end) if hasPass then --|| The player ownes the gamepass score.Value = 1500 else if not hasPass then --|| The player doesn't own the gamepass score.Value = 500 end while wait(60) do score.Value += 15 --|| Does the same thing as score.Value = score.Value + 15, you should get used to using this syntax end end end game.Players.PlayerAdded:Connect(onPlayerEntered) --|| Using PlayerAdded is more efficient