im trying to make a admin gui pls help
here is my code:
local plrn = script.Parent.Parent.PLRN.Text local plr1 = game.Players.LocalPlayer.Character local plr2 = game.Workspace:FindFirstChild(plrn) local btn = script.Parent btn.MouseButton1Down:Connect(function() plr1.HumanoidRootPart.CFrame = plr2.HumanoidRootPart.CFrame * CFrame.new(0,2,0) end)
Don't save that variable "plrn" with a textbutton.Text property (plrn = script.Parent.Parent.PLRN.Text), as it will save the current string, and if u later write on the textbox, the variable wont change. Instead, you have to save the textbox object on the variable and call the text property when you want to use it:
plrn = script.Parent.Parent.PLRN print(plrn.Text)
plr2 variable isnt set correctly, as it might find a game model instead of a player. Instead of finding a model inside the workspace, try finding a player inside game.Players and then finding its character, making sure to check if they exist:
plr2 = game.Players:findFirstChild(plrn.Text) if plr2 and plr2.Character then --teleport player here end
You will want to set and check plr2 just after clicking the button, so it finds a new player with the text everytime you click on the button. You are currently trying to find a player as soon as the script run, and that player will never change no matter what u type on that textbox. Here is how it should be like:
btn.MouseButton1Down:Connect(function() plr2 = game.Players:findFirstChild(plrn.Text) if plr2 and plr2.Character then plr1.HumanoidRootPart.CFrame = plr2.Character.HumanoidRootPart.CFrame * CFrame.new(0,2,0) end end)