-
What do you want to achieve? Keep it simple and clear!
i made a gui that if you input the user of someone it can fire an event and if the event if fired it checks the players rank who fired it and then compares it to the ingame target rank and if target’s rank is smaller than who fired it it changes the rank by -1 in the table to demote the target and then take 500 money to pay for it -
What is the issue? Include screenshots / videos if possible!
i made the local values work but at the if statement it just doesen’t do anything and just stops or errors whatever i try in it
heres the gui
heres the serverscript that handles it
heres the event
heres the localscript that fires it in the gui
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i have tried alott of different variations of it like doing it with local or without or removing if statements and i looked through alll of the scripts many times if there are errors but now theres no errors in the console it just fails to do the action
heres the serverscript (currently)
local ranks = {"Player", "Associate", "Soldier", "Gang Leader", "Officer", "Senior Officer", "Chief Officer", "Commander", "Overseer", "Captain", "Major", "General", "Boss", "Right Hand Men", "Godfather"}
game:GetService("ReplicatedStorage"):WaitForChild("demote").OnServerEvent:Connect(function(user, target)
local userrank = game:GetService("Players"):FindFirstChild(user.Name):WaitForChild("leaderstats", 5).Rank.Value
local usermoney = game:GetService("Players"):FindFirstChild(user.Name):FindFirstChild("leaderstats").Money.Value
local targetrank = game:GetService("Players"):FindFirstDescendant(target):FindFirstChild("leaderstats").Rank.Value
local userrankindex = table.find(ranks, userrank)
local targetrankindex = table.find(ranks, targetrank)
if targetrankindex < userrankindex then do
local indexfinal = targetrankindex - 1
local rankfinal = ranks[indexfinal]
targetrank = rankfinal
usermoney -= 500 --remove the cost
end
end
end)
heres the localscript
script.Parent.MouseButton1Click:Connect(function()
wait(1)
local target = script.Parent.Parent.user.Text
if target ~= nil and game:GetService("Players").LocalPlayer:WaitForChild("leaderstats",5):FindFirstChild("Money").Value >= 500 then
game:GetService("ReplicatedStorage").demote:FireServer(target)
end
end)
so can someone help me with it i think its the tables functions that arent working properly but i looked through every variation of google search queries and couldnt find anything about it because for other it worked.