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

Insert a variable into an object?

So In my Admin Panel GUI, I have a textbox where I type the player's name and click the "teleport to" button. However, I'm using a UI library. So I can make the variable whatever I want. I made it "text". The code for the button looks like this:

game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Players.text.Character.HumanoidRootPart.CFrame

But, the problem is that the game thinks that I'm to teleport to a player named "text", and of course there's no player named text. Is there a way I could insert the variable into the object?

section1:addTextbox("Player:", "Username Here", function(text, focusLost)
	print("Input", text)
	
	if focusLost then
		venyx:Notify("Player", text)
	end
end)

section1:addButton("Fastkill")
section1:addButton("Kill")
section1:addButton("Bring")
section1:addButton("Fastbring")
section1:addButton("Teleport To", function()
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Players.text.Character.HumanoidRootPart.CFrame
end)

(Section1 refering to a section in the gui.) (Lost focus referring to when the user loses focus of the textbox.)

2 answers

✓ Accepted answer

You are using a UI framework.

Every UI framework is different.

I think the answer should be:

local TargetPlayer = nil

local function GetPlayerFromString(String)
	local msg = String:lower()
	for _, v in pairs(game.Players:GetPlayers()) do
		local name = v.Name:lower():sub(0, msg:len())
		if name == msg then
			return v
		end
	end
	return nil
end

section1:addTextbox("Player:", "Username Here", function(text, focusLost)
    print("Input" .. text)
   TargetPlayer = text

    if focusLost then
        venyx:Notify("Player", text)
    end
end)

section1:addButton("Fastkill")
section1:addButton("Kill")
section1:addButton("Bring")
section1:addButton("Fastbring")
section1:addButton("Teleport To", function()
    game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = GetPlayerFromString(TargetPlayer).Character.HumanoidRootPart.CFrame
end)

Try not to ask for help on exploits too often, okay?

1 comment

0

Helps thanks! Also, I don't intend to cause harm. I mostly pen test my games.

You can use [Variable] to insert a variable in that case:

section1:addTextbox("Player:", "Username Here", function(text, focusLost)
    print("Input", text)

    if focusLost then
        venyx:Notify("Player", text)
    end
end)

section1:addButton("Fastkill")
section1:addButton("Kill")
section1:addButton("Bring")
section1:addButton("Fastbring")
section1:addButton("Teleport To", function()
    game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Players[text].Character.HumanoidRootPart.CFrame
end)

1 comment

0

When I try that the teleport too button doesn't click or do anything.

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