Ive been wondering this for a few days, I just can't figure out how I would get the game pass to enable the user to be teleported to a different level, like the one after they're on now, so if theyre on 3 and buy the pass to be skipped to 4 they get teleported there. Im not great at scripting, just begun learning.
Thanks in advance :)
going to try myself:
local passId = 0000000 -- change this to your game pass ID. function isAuthenticated(player) -- checks to see if the player owns your pass return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId) end game.Players.PlayerAdded:connect(function(plr) if isAuthenticated(plr) then stage = Player.leaderstats new_stage = stage + 1 function new_stage stage + 1 end end)
first ever try at code so please only useful feedback, thanks guys!
You could set up a value for which stage they are on, sort of like what you did, and add to it. Then, teleport the player to that position based on the value of the variable. To make it easier, you could name all the spawns for the stages Stage 1, Stage 2, etc. (If you don't want it like that, comment):
local passId = 0000000 -- change this to your game pass ID. function isAuthenticated(player) -- checks to see if the player owns your pass return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId) end game.Players.PlayerAdded:connect(function(plr) if isAuthenticated(plr) then stage = plr.leaderstats.Stage -- I added the .Stage because if I remember correctly, that's how it's set up. I'm also writing this assuming these are IntValues. if stage ~= (final stage) -- I assume you don't want them surpassing the maximum. Replace (final stage) with the last one. stage = stage + 1 plr.Character:MoveTo(game.Workspace:FindFirstChild("Stage " .. stage.Value).Position end end)
Hope this helped.
The way I would to this is set the players TeamColor to the TeamColor of the next level. Next you would need to teleport them to the next spawn or use :LoadCharacter()
Here is a little bit of pseudo code for how I would do this(Psuedo code is just Code in English):
--[[ You need to check that the player has the gamepass Now you need to check if what team the player is on Now you need to set the players TeamColor to the next level's TeamColor Now simply reload the character using :LoadCharacter --Note this must be done in a server script If you need to you can use a remote event to fire the server event that reloads the character A wiki link below will show you how to do this --]]