Image or Text does not show when RemoteEvent is called

Once the screen to the Point of Sales System is clicked, then it will show the LoginFrame. Once the user submitted their userId, it will then show their headshot and their userName on the SurfaceGui, showing that they claimed the POS. The Image and Text does not show while using the NumberValue or the StringValue. How shall I fix this?

ClaimLocal

local Screen = game.Workspace.Register.ClaimScreen
local ClickDetector = Screen.ClickDetector
local ClaimLogin = script.Parent.LoginFrame
local plr = game.Players.LocalPlayer
ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	print(playerWhoClicked.Name .. " = " .. tostring(playerWhoClicked.UserId))
	local clickedPlayerName = playerWhoClicked.Name
	local clickedPlayerNameValue = game.ReplicatedFirst.playerWhoClickedNameValue
	clickedPlayerNameValue.Value = clickedPlayerName
	local clickedPlayerUserId = playerWhoClicked.UserId
	local clickedPlayerUserIdValue = game.ReplicatedFirst.playerWhoClickedUserIdValue
	clickedPlayerUserIdValue.Value = clickedPlayerUserId
	ClaimLogin.Visible = not ClaimLogin.Visible
	if plr ~= playerWhoClicked then
		ClickDetector.MaxActivationDistance = 0
	end
end)

AcceptLocalScript

local ClaimLogin = script.Parent.Parent.Parent.Parent
local OrderingFrameThemeSettings = ClaimLogin.Parent.OrderingFrameThemeSettings
local ClaimedEvent = game.ReplicatedStorage.ClaimedRegister
local playerWhoClickedUserIdValue = game.ReplicatedFirst.playerWhoClickedUserIdValue.Value
local AcceptButton = script.Parent
AcceptButton.MouseButton1Click:Connect(function(p)
	ClaimedEvent:FireServer(playerWhoClickedUserIdValue)
	print(ClaimedEvent.Name.." is being fired!")
	ClaimLogin.Visible = false
	OrderingFrameThemeSettings.Visible = true
end)

ClaimScript

local LoginBox = game.StarterGui.OrderingScreenGui.LoginFrame.NumberPadFrame.InputBox
local playerWhoClickedNValue = game.ReplicatedFirst.playerWhoClickedNameValue.Value
local playerWhoClickedUIdValue = game.ReplicatedFirst.playerWhoClickedUserIdValue.Value
local ClaimedEvent = game.ReplicatedStorage.ClaimedRegister
local function changeScreen()
	local RegisterUserLabel = game.Workspace.Register.ClaimScreen.ClaimGui.MainImageLabel.UserLabel
	local RegisterUserImage = game.Workspace.Register.ClaimScreen.ClaimGui.MainImageLabel.UserImageLabel
	RegisterUserLabel.Text = playerWhoClickedNValue
	RegisterUserImage.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=" ..playerWhoClickedUIdValue.. "&width=420&height=420&format=png"
	print(ClaimedEvent.Name.." was fired!")
end
ClaimedEvent.OnServerEvent:Connect(changeScreen)
1 Like

Use this instead:
Players | Documentation - Roblox Creator Hub

Can you print out the playerWhoClickedNValue?

3 Likes

The playerWhoClickedNValue logs the person’s username for when they click on the register screen as shown in the first LocalScript. Here is what I thought it would do. The Value would concatenate into the TextLabel, which I see now that it doesn’t put it into print.
Screenshot 2024-10-01 052001

When I use the below, it shows an error, “PlayerAdded is not a valid member of Player “Players.chrma””.

local LoginBox = game.StarterGui.OrderingScreenGui.LoginFrame.NumberPadFrame.InputBox
local ClaimedEvent = game.ReplicatedStorage.ClaimedRegister
local Player = game:GetService("Players")
local function changeScreen(Player)
	Player.PlayerAdded:Connect(function(p)
		local userId = p.UserId
		local plrName = p.Name
		local RegisterUserLabel = game.Workspace.Register.ClaimScreen.ClaimGui.MainImageLabel.UserLabel
		local RegisterUserImage = game.Workspace.Register.ClaimScreen.ClaimGui.MainImageLabel.UserImageLabel
		print(plrName.." = "..userId)
		RegisterUserLabel.Text = plrName
		RegisterUserImage.Image = "https://www.roblox.com/headshot-thumbnail/image?userId=" ..userId.. "&width=420&height=420&format=png"
	end)
	print(ClaimedEvent.Name.." was fired!")
end
ClaimedEvent.OnServerEvent:Connect(changeScreen)
1 Like

I think you have some misunderstandings with how the client and server interact. Changing any values in replicated storage won’t change it on the server, that only works on specific values that the client has network ownership of, such as their character location and Humanoid WalkSpeed. What you’re trying to can be achieved by just the remote event though; I’ll show you some examples:

Simple script that prints the name of the player who fired the remote event

--Client
remoteEvent:FireServer()
--Server
remoteEvent.OnServerEvent:Connect(function(playerWhoFired)
print(playerWhoFired.Name)
end)

The remote event automatically passes the player who fired the event as a parameter to the server, you don’t have to do it manually.

Simple script that would get you the image url of a players headshot after they trigger a remote event

--Client
remoteEvent:FireServer() -- literally exactly the same, as you only need the player instance in the server to do what we want to do, nothing else
--Server
remoteEvent.OnServerEvent:Connect(function(playerWhoFired)
local ImageURL = "https://www.roblox.com/headshot-thumbnail/image?userId=" ..playerWhoFired.UserId.. "&width=420&height=420&format=png"
end)
1 Like

You don’t need “Player.PlayerAdded:Connect(function(p)” this line, as long as you remove it, it should work.

1 Like

Yes, the RemoteEvents article did get me confused while experimenting with it. Such a lifesaver. Thank you!

1 Like