Need help on scripting ranking error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Promotes you to the correct rank instead of E2/E3.
  2. What is the issue? Include screenshots / videos if possible!
    I clicked E8/E9 rank, however, it just promotes me up to E2/E3 no matter what then kicks me after I click on it.
Main for the promoting script:

local HttpService = game:GetService("HttpService")
local Server = require(script.Server)

game.ReplicatedStorage.RankPlayer.OnServerEvent:Connect(function(player, rank)
    local groupId = 2941416
    Server.Promote(groupId, player.UserId)
end)
script.Parent.MouseButton1Click:Connect(function()
    local plr = game.Players.LocalPlayer
	local Player = game.Players.LocalPlayer
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 8701692) then
    local rankid = 8 --This is the rank that the user will be promoted/demoted to.
       game.ReplicatedStorage.RankPlayer:FireServer(game.Players.LocalPlayer, rankid)
	wait(5) Player:Kick("You've been ranked!")
else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 8701692)
    end
end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried attempting to change it to Server.SetRank, however I’d need another way for the rankid for the specific rank instead of Server.Promote which just promotes you up one sadly…

You’re passing yourself to the server, so just do game.ReplicatedStorage.RankPlayer:FireServer(rankid). Roblox already knows which player fired the remote, so doing it yourself is not needed.

Do I do it for the top one or what??

correct


function Test(PlayerThatFiredRemote,TheLocalPlayerSentOver,rankid)

end

game.ReplicatedStorage.RankPlayer.OnServerEvent:Connect(Test)

see how there is 2 of the same player in the function?

when you are firing RankPlayer, all you would have to do is

game.ReplicatedStorage.RankPlayer:FireServer(rankid)

the RemoteEvent already gets the player that fired it

So game.ReplicatedStorage.RankPlayer:FireServer(game.Players.LocalPlayer, rankid)

"game.Players.LocalPlayer"

was messing up the rank id of what the person was supposed to be ranked too?

Okay, so I demoted myself to E1, then I changed it to

game.ReplicatedStorage.RankPlayer:FireServer(rankid)

However, I just got promoted back to E2/E3 after I clicked on E8/E9 button…

well for some reason you have 2 variables for the same player

script.Parent.MouseButton1Click:Connect(function()
    local plr = game.Players.LocalPlayer
	local Player = game.Players.LocalPlayer
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 8701692) then
    local rankid = 8 --This is the rank that the user will be promoted/demoted to.
       game.ReplicatedStorage.RankPlayer:FireServer(game.Players.LocalPlayer, rankid)
	wait(5) Player:Kick("You've been ranked!")
else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 8701692)
    end

you should only need one and no you aren’t, but you you need to remove the game.Players.LocalPlayer from the line where you fired the RemoteEvent

script.Parent.MouseButton1Click:Connect(function()
    local plr = game.Players.LocalPlayer
	local Player = game.Players.LocalPlayer
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 8701692) then
    local rankid = 8 --This is the rank that the user will be promoted/demoted to.
       game.ReplicatedStorage.RankPlayer:FireServer(rankid)
	wait(5) Player:Kick("You've been ranked!")
else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 8701692)
    end

Yes I did change it, however…when I demoted myself to E1, and went to the rank center. I clicked on E8/E9 button rank, but it promoted me to E2/E3 after I left the game and checked.

correct

im typing this to make it 30 characters

So then none of you guys know the solution then…?

what do you mean, i gave you the solution

script.Parent.MouseButton1Click:Connect(function()
    local plr = game.Players.LocalPlayer
	local Player = game.Players.LocalPlayer
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 8701692) then
    local rankid = 8 --This is the rank that the user will be promoted/demoted to.
   "game.ReplicatedStorage.RankPlayer:FireServer(rankid)"


	wait(5) Player:Kick("You've been ranked!")
else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 8701692)
    end

How is “game.ReplicatedStorage.RankPlayer:FireServer(rankid)”

the solution, when it promotes me to the wrong rank?

local HttpService = game:GetService("HttpService")
local Server = require(script.Server)

game.ReplicatedStorage.RankPlayer.OnServerEvent:Connect(function(player, rank)
    local groupId = 2941416
    Server.Promote(groupId, player.UserId)
end)
This script ranks a user to the desired rank when an event is fired.

well then there is more than one error, so that was a solution to that problem.

when you do

 Server.Promote(groupId, player.UserId)

you arent even sending the rank you want them to have, you are just sending the group id and the userid

Server.SetRank = function(GroupId, UserId, RankId)
	assert(typeof(GroupId) == "number", "Error: GroupId must be an integer") -- Throw error if GroupId is not an integer
	assert(typeof(UserId) == "number", "Error: UserId must be an integer") -- Throw error if UserId is not an integer
	assert(typeof(RankId) == "number", "Error: RankId must be an integer") -- Throw error if RankId is not an integer

	local Body = {
		Group = GroupId;
		Target = UserId;
		Rank = RankId;
	}
	
	local Success, Result = pcall(function()
	    return Request('SetRank', Body)
	end)
	
	print(Result)
end

Then how would I be able to change it to

local HttpService = game:GetService("HttpService")
local Server = require(script.Server)

game.ReplicatedStorage.RankPlayer.OnServerEvent:Connect(function(player, rank)
    local groupId = 2941416
    Server.SetRank = function(GroupId, UserId, RankId)
end)

local RankId is missing in order to complete it, so I don’t really know at the moment anymore.

alright dude, do you have discord, i can tell you much easier on there