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

".." Won't work to get a player by text in a textbox?

So normally on ROBLOX you can just do

game.Players..ITEM.Text 

etc..

For some reason this is not working, I tried something different but it won't work and nothing appears in "Output" The code is as followed.

local namelol = script.Parent.Parent.Name.Text
local row = script.Parent.Parent.Row.Text
local num = script.Parent.Parent.SeatNumber.Text


script.Parent.MouseButton1Click:Connect(function()
	if row == "A" and num == 1 then
		game.Players.namelol.Character.HumanoidRootPart.CFrame = workspace.A_One.CFrame * CFrame.new(0, 3, 0)
	else
		if row == "A" and num == 2 then
			game.Players.namelol.Character.HumanoidRootPart.CFrame = workspace.A_Two.CFrame * CFrame.new(0, 3, 0)
		else
			if row == "A" and num == 3 then
				game.Players.namelol.Character.HumanoidRootPart.CFrame = workspace.A_Three.CFrame * CFrame.new(0, 3, 0)
			end
		end
	end
	
end)

I do know how to script and all that but I can't find an object via something's text.

2 answers

✓ Accepted answer

If you want to index objects w/ dynamic strings, then you can use FindFirstChild() or square brackets [ ].

Ex:

game.Players:FindFirstChild(namelol).Character.HumanoidRootPart.CFrame
game.Players[namelol].Character.HumanoidRootPart.CFrame

2 comments

0

You might want to define the variables within the event callback though, so it'll be the most recent text of the objects.

0

Thank you very much for your answer!

You're indexing the player's name the wrong way. Instead, you should use square parantheses [ ]. Like this:

game.Players[namelol].Character.HumanoidRootPart.CFrame = workspace.A_One.CFrame * CFrame.new(0, 3, 0)

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