#Gamepass not given when bought, player has to rejoin
65 messages · Page 1 of 1 (latest)
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 744120513 -- Change this ID to your Gamepass ID
local ToolName = "SuperGravityCoil" -- Change YourToolName to whatever you tool is called
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
script[ToolName]:Clone().Parent = player.Backpack
end
end)
end)
All you do is check if the player owns the game pass on entry, so the problem at hand is actually by design
You'll need to listen for MarketplaceService.PromptGamePassPurchaseFinished and follow up with its parameters to identify what code to execute when the game pass is bought
How would I fix that? I'm very new to scripting I watched a video on this script
** You are now Level 1! **
Unfortunately, fixing this is out of your depth if you're a beginner scripter
Oh
Only way they get it is if they reset or rejoin basically if their character respawns
check every time
Unfortunately, MarketplaceService:UserOwnsGamePassAsync caches the initial query, so if the game-pass is not owned at the time the player enters the server, it will still be viewed as such until they rejoin
Like I said, solving this is out of your depth as a beginner scripter
I can show you what the solution looks like though
#448986885570691103
@amber hatch
So, yeah, as you can see, lol
Lol
Alot of info
Is it possible if I can make it so once bought it respawns the player
Because the game is an obby and even if they respawn it will be at a checkpoint
Absolutely. It would be matter of calling Player:LoadCharacter or killing the player in the game-pass/develop product handler function
Uh, a question I dont mind if you say no. Not being rude but is it possible if you can do it?
Because I mostly build and scripting isn't my thing as this game is a little project, I got most things working but this is basically the final issue I have
I'm sorry, no. That code was labour on my part, and I'm not willing to give it away for free
^
LoadCharacter would be just a reset but quicker?
Yes
Okay
You can alternatively reduce the objective respawn time to the lowest possible number
Thanks alot, I'll let you know how it goes.
💪
Generally, an approach like mine is recommended. Roblox's documentation on MarketplaceService.ProcessReceipt implements the same system, but in a way that isn't good for scalability
My pea brain don't understand lol
Ill think abt it
Players.RespawnTime controls the global respawn time. If you drop this number to zero, killing the player should be as fast as calling Player:LoadCharacter
This is something to consider when the 5 second respawn time after falling into the void gets annoying
Especially for an obby
Ahhh
** You are now Level 2! **
Could I include the script in the same script?
I also used some AI for help
I'm not sure what you're asking
can you tell me the plot of what you explained?
I’m interested
The respawn script to respond the character in the same script I shown
In order to reduce code duplication, improve scalability and organization, and bypass Roblox's static cache, you would need to centralize game-pass and developer product implementations. You can then load them into a lookup which is devided into two sections for the respective assets and events. It is then a matter of identifying the implementation by its asset ID, as given by the events, and calling its handler function with the associated player. You can build your own ownership cache as the player buys game-passes in-game, and similarly call all game-pass handlers on entry to give what's owed
It's not complicated, but it is work
Or does it need to be seperate
Why reset the character when they enter the game?
Wait what
Can the script I make for this be added into the same one I'm using
That I shown at first
No. Your code will run every time the character spawns. If you initiate a re-spawn, the code will enter a never-ending cycle, which will eventually kill the event handler
Oh
So I should try something like this