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.)
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?
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)