I’m hoping someone has the adequate knowledge to convert the LocalScript provided below in to a serverside script most likely using a RemoteEvent, as I’m unsure of how to do so myself. To describe what the script does - it’s for a hosting gui at my training center. It changes the overhead rank name of the inputted player’s username. Let me know if you can assist with converting this script to serverside; thank you in advance!
local rankButton = script.Parent.Parent.TextButton
rankButton.MouseButton1Down:Connect(function()
local characters = string.lower(script.Parent.Text)
for i, player in pairs(game.Players:GetChildren()) do
local plrName = string.lower(player.Name)
if string.sub(plrName,1,#characters) == characters then
player.Character.Head.Rank.Frame.Name1.Text = "test"
end
end
end)
If you’d like to change something from the client to all players, here is a method using a RemoteEvent.
You can create a RemoteEvent inside of ReplicatedStorage and call it something, for example “TextEvent”.
The server script can be what is shown bellow:
local Event = game.ReplicatedStorage:WaitForChild("TextEvent") -- Define the event
Event.OnServerEvent:Connect(function(plr, text)
local Characters = string.lower(text)
for i, player in pairs(game.Players:GetPlayers()) do
local PlrName = string.lower(plr.Name)
if string.sub(PlrName, 1, #Characters) == Characters then
plr.Character.Head.Rank.Frame.Name1.Text = "Test" -- Change to the text variable if you'd like to pass custom text
end
end
end)
And the local script:
local TextEvent = game.ReplicatedStorage:WaitForChild("TextEvent")
local RankButton = script.Parent
RankButton.Activated:Connect(function()
TextEvent:FireServer("Text") -- You can change the text with whatever you'd like
end)
Although I’m giving you code now, next time I suggest finding tutorials/searching the dev forum for an answer.
You can use GetUserThumbnailAsync to get the thumbnail of the player and change it with that. the page with the text highlighted in blue should give you a good explanation of how it should be done and also provides you with an example
Anytime! If you have anymore issues with your scripts you can reply with your issue, or alternatively if you have a separate issue, you can make another post!
Well the first thing I notice is that in the FireServer you gave it “” as a parameter, which means nothing. The issue with that is that means it’ll set any player on that role regardless of what you type. Did you mean to set the parameter as the Textbox’s text?
Also if you want to reliably test this, you’ll have to make a local server and test it from there since you’re only player there
The thing is, when I put some text in the parameter it doesn’t work. What script would I put in to set the parameter as the TextBox’s text? Also, I did test it on a local server in studio with 2 players!
This seems to have worked, thank you so much! The only issue now is when there is NO text in the TextBox, it’ll execute the script on the player who clicked the button. (It works as expected when there is a username in the TextBox, though.) How could I make it so it doesn’t do anything when there is no text in the TextBox?
That will only make it execute the code inside if the text is not nothing/empty. Also, .Text must have a capital t cause case sensitivity. The code you provided now that I see w ouldn’t work eitherways since = is used as an assignment operator