What do you want to achieve? Keep it simple and clear!
I want to copy over the name of the player that clicks a button onto a surface gui, so each time a player clicks it the surface gui records their name and makes a list of players that clicked it.
What is the issue? Include screenshots / videos if possible!
The issue is I have only managed to be able to get the first two players to click it, so the third player to click it does not have their name copied and I am not sure why.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tired changing my elseif conditions to copy the third players name but nothing has changed. I even have “warn(“3”)” to check if it prints and it does not.
game.ReplicatedStorage.RemoteFunction4.OnServerInvoke = function(player)
local content = player.Name
local TextLabel = game.Workspace.TestPart4.SurfaceGui.TextLabel
local TextLabel2 = game.Workspace.TestPart4.SurfaceGui.TextLabel2
local TextLabel3 = game.Workspace.TestPart4.SurfaceGui.TextLabel3
if TextLabel.Text == '' then
TextLabel.Text = content
warn("1")
elseif TextLabel.Text == content then
TextLabel2.Text = content
warn("2")
elseif TextLabel2.Text == content then
TextLabel3.Text = content
warn("3")
end
end
I know my issue is with my last elseif, but idk what it could be?
UPDATE: Last elseif still not working AND I just realized it only takes the name of the first player to click it… So I have to fix that too but also do not know how?
You probably want a function to create a new label. Then if someone clicks on the gui, and they haven’t already clicked on it, then call the function.
To check if they clicked on it already, you could create a table to keep track.
To be honest I have no idea how checking if the text is equal to the player’s name is going to create a list of players who have clicked the gui.
I actually got it to work, I just had to pass the player.name from the local script to the server script. So now it works and it gets the name of the player that clicks it but I still do not know how to make the third elseif work. This is the updated script btw:
game.ReplicatedStorage.RemoteFunction4.OnServerInvoke = function(player,content)
local TextLabel = game.Workspace.TestPart4.SurfaceGui.TextLabel
local TextLabel2 = game.Workspace.TestPart4.SurfaceGui.TextLabel2
local TextLabel3 = game.Workspace.TestPart4.SurfaceGui.TextLabel3
if TextLabel.Text == '' then
TextLabel.Text = content
warn("1")
elseif TextLabel.Text ~= '' then
TextLabel2.Text = content
warn("2")
elseif TextLabel2.Text ~= '' then
TextLabel3.Text = content
warn("3")
end
end
UPDATED I figured it out! c: Here is the working script, it will copy the player that click the button’s name onto the next empty textlabel in the surfacegui!
game.ReplicatedStorage.RemoteFunction4.OnServerInvoke = function(player,content)
local TextLabel = game.Workspace.TestPart4.SurfaceGui.TextLabel
local TextLabel2 = game.Workspace.TestPart4.SurfaceGui.TextLabel2
local TextLabel3 = game.Workspace.TestPart4.SurfaceGui.TextLabel3
if TextLabel.Text == '' then
TextLabel.Text = content
warn("1")
elseif TextLabel.Text ~= '' and TextLabel2.Text == '' then
TextLabel2.Text = content
warn("2")
elseif TextLabel2.Text ~= '' and TextLabel3.Text == '' then
TextLabel3.Text = content
warn("3")
end
end