How to get a humanoid root part from a string value

So I’m trying to make a super simple admin/debugging thing where I can do commands by using the F9 command prompt, but I’m stuck on this error:
12:44:16.930 Workspace.Admin.AdminScript:63: attempt to index nil with ‘Character’ - Server - AdminScript:63
The teleporting part does not work with finding the humanoid, also maybe the CFrame doesnt work either but I have not tested that yet because its stuck on humanoid part.

local S = script.Parent.Scare -- Jumpscare
local D = script.Parent.Day -- Day set
local TP = script.Parent.TP -- Teleporting to XYZ
local User = script.Parent.User -- User Selected

S.Changed:Connect(function()
	local m = game.Lighting.ColorCorrection4roguard
	game.SoundService.Sound2.TimePosition = 0    
	game.SoundService.Sound2.Playing = true
	wait(3)
	for x = 0,-1,-0.05 do
		m.Saturation = x
		wait(0.1)
	end
	for x = 0,-0.7,-0.05 do
		m.Brightness = x
		wait(0.2)
	end
	wait(3)
	game.SoundService.Sound3.TimePosition = 0    
	game.SoundService.Sound3.Playing = true
	wait(4)
	for x = -0.2,0,0.05 do
		m.Brightness = x
		wait(0.2)
	end
	for x = -0.7,0,0.05 do
		m.Saturation = x
		wait(0.1)
	end
end)
D.Changed:Connect(function()
	local p = tonumber(D.Value)
	if p then
		local sr = game.Lighting.SunRays
		local s = game.Lighting.skybox
		local a = game.Lighting.Atmosphere
		local t = game.Workspace.Terrain
		local n = 167*D.Value
		local n2 = 0.02*D.Value
		local d = game.Workspace.Day
		local n = D.Value*3
		game.Lighting.OutdoorAmbient = Color3.fromRGB(n, n, n)
		d.Value = D.Value
		t.WaterWaveSize = d.Value/10
		t.WaterWaveSpeed = d.Value
		sr.Intensity = 0.302+n2
		s.SunAngularSize = 1.15^D.Value
		s.StarCount = 5000-n
		local n = 101 + d.Value
		local x = s.SunAngularSize
		t:SetMaterialColor(Enum.Material.Grass, Color3.fromRGB(n, 126, 62))
		game.Workspace.GlobalWind = Vector3.new(x,0,0)
		if d.Value >= 29 then
			a.Haze = 3
		else
			a.Haze = 1
		end
	end
end)
TP.Changed:Connect(function()
	local player = game.Players:FindFirstChild(User.Value)
	local character = player.Character
	local str = TP.Value -- stringified cframe
	local cefra = str:split(",")
	character:PivotTo(CFrame.new(unpack(cefra)))
	
end)

You have to use this to go through and find the character:

local LocalPlayer = game:GetService("Players").LocalPlayer
TP.Changed:Connect(function()
   local Character = LocalPlayer.Character
    if not  (Character)  then return end
   local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
   if not (HumanoidRootPart) then return end
   -- code to move the humanoidrootpart to TP location? your code is confusing sorry
HumanoidRootPart.CFrame = CFrame.New(1,1,1) -- Change this to where you want them to go
end)

I tried to help you best I can but your code doesn’t quite lineup with how to get the players HumanoidRootPart and change it’s CFrame.

It is a server script, it has a value that has the user its trying to TP, and then another value that gives the TP location; local player will not work on a server script. It would be activated when a developer presses F9, goes to server, and types “game.Workspace.Admin.TP.Value = 1,1,1” or something. I just don’t know how to get their character/humanoidrootpart from just the name alone.

never mind, I’m an idiot I could just use any admin TP script for help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.