When I click on the button the text changes but it does not rank or send any request. I have not idea why
--Local Script
local HttpService = game:GetService("HttpService")
local TextService = game:GetService("TextService")
local data
local one = false
local two = false
script.Parent.MouseButton1Click:Connect(function()
if not script.Parent.Parent.rankbutton == "Rank" then
script.Parent.Text = "You may only rank 1 at a time"
wait(0.5)
script.Parent.Text = "Promote"
two = false
end
local username = script.Parent.Parent.username.Text
if not username then
script.Parent.Text = "Please type a username!"
wait(0.5)
script.Parent.Text = "Promote"
one = true
end
if one == false and two == false then
game.ReplicatedFirst.Promote:FireServer(username)
script.Parent.Text = "Promoting...."
end
end)
--Server Script
local HttpService = game:GetService("HttpService")
local TextService = game:GetService("TextService")
local ApiKey = game.ServerStorage.Settings.ApiKey.Value
local data
print(2)
game.ReplicatedFirst.Promote.OnServerEvent:Connect(function(plr, username, ApiKey)
print(1)
local username = plr.PlayerGui.RankingGui.Frame.username.Text
local Gui = game.Players[plr.Name].PlayerGui.RankingGui
if not ApiKey then
Gui.Frame.rankbutton.Text = "Error! No Apikey set!"
wait(0.5)
Gui.Frame.rankbutton.Text = "Promote"
end
pcall(function()
local responce = HttpService:PostAsync('https://api.rankblox.tk/promote?apiKey='.. tostring(ApiKey)'&Username='.. tostring(username)'&RankerId='.. tostring(plr.UserId))
data = HttpService:JSONDecode(responce)
end)
if not data then
Gui.Frame.promotebutton.Text = "Error! Try again later."
wait(0.5)
Gui.Frame.promotebutton.Text = "Promote"
else
Gui.Frame.promotebutton.Text = "Promoted!"
wait(0.5)
Gui.Frame.promotebutton.Text = "Promote"
end
end)