You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Promotes you to the correct rank instead of E2/E3.
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)
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.
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.
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.
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.
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)