hello there I’m trying to take user input to set ranks
custom rank is the button and 1111 is the rank for it to set
in the code bellow
script.Parent.rankdata.Text
is the user input 1111
whenever I click on it sets the rank to nil
local Remote = script.Parent.RemoteEvent
Remote.OnServerEvent:Connect(function(plr)
local main = _G.HDAdminMain
main:GetModule("cf"):SetRank(game:GetService("Players")[plr.name], game.CreatorId, script.Parent.rankdata.Text, "Perm")
end)
Because the TextBox text is being set on the client, you will need to pass the text through a remote as trying to get a client change on the server will return false results.
When firing the remote, just add an argument that gets the TextBox text. Then just change how the text is set, like so.
local Remote = script.Parent.RemoteEvent
Remote.OnServerEvent:Connect(function(plr,text)
local main = _G.HDAdminMain
main:GetModule("cf"):SetRank(game:GetService("Players")[plr.name], game.CreatorId, text, "Perm")
end)
Like I said, you will need to add an argument for when you are firing the remote that sends the TextBox text. If you don’t know how to do that I recommend you try to learn more about remotes.
That’s the line of code which causes the issue, you’re referencing the Text at the current moment in time, and thus it remains constant. Instead you should reference rankdata as:
local rankdata = script.Parent.rankdata --without the .Text!
Also the local text = script.Parent.rankdata.Text line should be removed from the server script and added to your client script(but in the way I told above). Then when the button is pressed fire the remote as Remote:FireServer(rankdata.Text).