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

How do I make this GUI handle a tool to a specified player in-game?

In this GUI you input the player's name on a TextBox and when you click on a TextButton it should give the player inputted in the TextBox an economy ticket.

This is the script inside the TextButton

function o()
	local text = "game.Players."..script.Parent.Parent.UsernameBox.Text
	print(text.Name)
	local plr = text
	script.Economy:Clone().Parent = plr.Backpack
end

script.Parent.MouseButton1Click:Connect(o)

It does call the function, I just don't know how to make it find the player I want. Please help me!

1 answer

✓ Accepted answer

Hey, I noticed your problem immediately. It's on line 4.

local plr = text

You set the variable 'plr' to a string ("game.Players.TEXT"). That doesn't actually locate the player here's your script fixed:

function o()
    local text = game.Players:FindFirstChild(script.Parent.Parent.UsernameBox.Text) -- This checks inside of game.Players for the playername that was entered. It's not a string, and the variable is a player object variable.
    print(text.Name)
    local plr = text
    script.Economy:Clone().Parent = plr.Backpack
end

script.Parent.MouseButton1Click:Connect(o)

Hope this helps and if it does be sure to accept it as the answer :)

1 comment

0

Thanks!

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