Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I made a player.name script and it didnt work can someone help?

Here's the local script.

player = game:GetService("Players"):GetPlayers()
local function onClicked(GUI)
	script.Parent.Parent.Parent.Parent.Parent.Parent.TableSystem.Table.Visible = true
	script.Parent.Parent.CBUsername.Text = player.Name
end
script.Parent.MouseButton1Click:Connect(onClicked)

It didn't work. Here's the output.

16:18:46.683 - Players.raid6n.PlayerGui.Waiter/Waitress Board.TextButton.Page1.Order1.Claim.LocalScript:4: bad argument #3 to 'Text' (string expected, got nil)

Help?

1 answer

✓ Accepted answer

You have not defined player, you are trying to get a string of a service (which isn't possible).

You can do this.

local Players = game:GetService('Players')
local Player = Players.LocalPlayer

local function onClicked()
    script.Parent.Parent.Parent.Parent.Parent.Parent.TableSystem.Table.Visible = true
    script.Parent.Parent.CBUsername.Text = Player.Name
end
script.Parent.MouseButton1Click:Connect(onClicked)

1 comment

1

tysm

This discussion is preserved as it was. New answers, comments, and votes are closed.