local ReplicatedStorage = game:GetService("ReplicatedStorage")
local groupId = 6413194
local api = require(4690204259)("domain", "key", groupId)
local TeleportService = game:GetService("TeleportService")
local gameID = 5074720976
ReplicatedStorage.Events.Promote.RequestPromotion.OnServerEvent:Connect(function(Player, RankId)
if Player:GetRankInGroup(groupId) ~= groupId then
print(api.setRank(Player.UserId, RankId)) -- Change 5
TeleportService:Teleport(gameID, Player)
end
end)
Above is a server script for an API system I use to rank players.
So let me sum this up the best I can:
I am creating a LGBTQ+ hangout where when you join the game, if you’re already in the “ROBLOX Pride” group, and you click “Choose Orientation” it allows you to pick your orientation. The API system works fine, however - I am trying to make it so after you’ve chosen your orientation it forces you to rejoin the game in order for your in-game orientation to update.
I figured the best way to go about this was to implement it where the server handles the RemoteEvent. The API system still works fine and continues to promote my alt, however it is not teleporting me back to the game and isn’t giving me any errors.
If you’re looking to create a rejoin system, simply passing game.PlaceId to teleport would be sufficient enough here instead of hard passing a place id. Your teleport could be failing to initialise as well or you just aren’t waiting enough before determining that it doesn’t work.
There’s no actual problem that can be found in this code other than nitpicks such as how you make players rejoin, the fact that your remote has zero security and all that (why allow a player to pass a RankId when you can pass an identifier string and have the server perform a lookup in a dictionary?).
The time it takes for a teleport to complete can be variable. You can use TeleportInitFailed to check when a teleport fails to see what happened in that regard, otherwise don’t have anything for you.
For a different answer: you shouldn’t make players rejoin just to have their group stuff update. You have to realise that caching exists and players won’t necessarily pull new data through a rejoin. Also, interrupting the game experience for something so trivial, especially like a rank, is bad for UX.
GroupService contains a non-caching function which can fetch a user’s groups and their standings in it. Making players rejoin to update their ranks is bad for UX, you should just update that content in the current session based on the selection and allow them to continue playing uninterrupted.
Well I must be doing something wrong? And I will try the LoadCharacter function, but I’d like to try this first.
When did this error start occurring and what did you change before it started happening? You said there were no errors and now you’re reporting a nil index error attempt.
Also, I didn’t say anything about LoadCharacter. I meant that you should update any relevant data within the current session using available tools. LoadCharacter just respawns the character and you don’t need to do that to update a player’s rank. If they have an overhead nametag, just change its text (and colour if applicable), that’s all.