LocalScript in to ServerSide

Yes, you’re exactly right! (30 ch.rs)

Eek, also, the images of the player don’t appear when I test it in a 2 player server on studio. :frowning:

I’m not sure how that would as I never did sometihng like that, there should be a guide somewhere on how do that since it would be something a most people would want to add

Does it only appear for you or for no one, it could be cause the image is not ready to be used

inside of the if statement, perhaps change the code to

player.Character.Rank.Frame.TextLabel.Text = "Host"
player.Team = game.Teams.Host
local ready, img
repeat
	img, ready = game.Players:GetUserThumbnailAsync(player.UserId,thumbtype,thumbsize) --Create Image
until ready
end
for _,plrs in pairs(players) do --Loop through players again to set the image
	plrs.PlayerGui.(proceed with location of image label).Image = img
end
break --Stop the first loop since we found our player

Alright, thanks! (30 ch.rssssss)

It appears for no one, do I change the code to that if it appears for no one?

Edit: it appears for me when I test it in studio by myself, but not when I test it in studio with 2+ players.

If it’s not appearing for anyone, then it has to be taht image is not not yet ready to use, try it out

Edit: Again, even then, it still should be that the image is not ready in time, probably cause it “maybe” takes longer if there’s more players, is it only the image or is the rank and what not not be changed either? It’s still best to that out and see if it works

1 Like

Check the edit! (30 ch.rssssssss)

It’s just the image! I’m getting an error when testing the script once updated, I think we’re missing an end somewhere.

image

Wait ithink I see why, I added an end after until ready, remove that

Okay, give me one second to do so.

1 Like

Still not working, unfortunately… :frowning:

Sorry about all of this trouble…

Odd, I think there needs to be a print to help debug what is going to see if it 's actually the img not being loaded, try adding some prints somewhere in the if statement to debug

Alright, is this okay:

local Event = game.ReplicatedStorage:WaitForChild("HostRole")

local thumbsize = Enum.ThumbnailSize.Size60x60
local thumbtype = Enum.ThumbnailType.HeadShot --The type of image you want

Event.OnServerEvent:Connect(function(plr, text)
	local players = game.Players:GetPlayers()
	local Characters = string.lower(text)

	for i, player in pairs(players) do
		local PlrName = string.lower(player.Name)

		if string.sub(PlrName,1,#Characters) == Characters then
			player.Character.Rank.Frame.TextLabel.Text = "Host"
			print("Role text changed!")
			player.Team = game.Teams.Host
			print("Player teamed to Host.")
			local ready, img
			repeat
				img, ready = game.Players:GetUserThumbnailAsync(player.UserId,thumbtype,thumbsize) --Create Image
				print("Created image.")
			until ready
		for _,plrs in pairs(players) do --Loop through players again to set the image
				plrs.PlayerGui.RoleGui.ImageLabel.Frame.HostPanel.Host.Image = img
				print("Set the image.")
		end
		break --Stop the first loop since we found our player
		end
	end
end)

?

Somethign like that’ll work yes, try it out

1 Like

Is this where it should be printing stuff, because it’s not doing it…

Then the issue is somewhere outside of the if statement them, it’s not finding the right player, show me your entire code as of now so I can see where could be debugged/the isuse

1 Like

Okay, I’ve provided links below.

Server with 1 player:
https://drive.google.com/file/d/1c2RlIuKnqwmEv3Um_Vzmy00weW6FCEKG/view

Server with multiple players:
https://drive.google.com/file/d/1evQlVxnubweSiwgZzydhgjVSMWbDeL2q/view
^ I’m not sure what happened at the end there when trying to role Player1.
Also: please ignore the Discord in the background… :sob:

ServerScript:

local Event = game.ReplicatedStorage:WaitForChild("HostRole")

local thumbsize = Enum.ThumbnailSize.Size60x60
local thumbtype = Enum.ThumbnailType.HeadShot --The type of image you want

Event.OnServerEvent:Connect(function(plr, text)
	local players = game.Players:GetPlayers()
	local Characters = string.lower(text)

	for i, player in pairs(players) do
		local PlrName = string.lower(player.Name)

		if string.sub(PlrName,1,#Characters) == Characters then
			player.Character.Rank.Frame.TextLabel.Text = "Host"
			print("Role text changed!")
			player.Team = game.Teams.Host
			print("Player teamed to Host.")
			local ready, img
			repeat
				img, ready = game.Players:GetUserThumbnailAsync(player.UserId,thumbtype,thumbsize) --Create Image
				print("Created image.")
			until ready
		for _,plrs in pairs(players) do --Loop through players again to set the image
				plrs.PlayerGui.RoleGui.ImageLabel.Frame.HostPanel.Host.Image = img
				print("Set the image.")
		end
		break --Stop the first loop since we found our player
		end
	end
end)

LocalScript:

local TextEvent = game.ReplicatedStorage:WaitForChild("HostRole")
local RankButton = script.Parent

RankButton.Activated:Connect(function()
    TextEvent:FireServer(script.Parent.Parent.Parent.UsernameBox.TextBox.Text)
end)

Okay after

local PlrName = string.lower(player.Name)

add

print(PlrName, Characters)

So we can see what players it can see when doing the loop

Also I think we should move this to messages so we don’t keep flooding this

1 Like