So I’m making an admin script that allows you to tp players to you. Following this right here. MAKE ADMIN COMMANDS - Roblox Scripting Tutorial (Advanced) - YouTube When I try to teleport, it comes up with this error.
What does it mean by CFrame isn’t a valid member. Here is the script and the errors are in lines 33 and 60.local commands = {}
'local prefix = “/”
local function findPlayer(name)
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player -- Returned a player object
end
end
return nil
end
commands.tp = function(sender, arguments) – Sender: Object / arguments: table
print("TP function fired by "..sender.Name)
for i, playerName in pairs(arguments) do
print(playerName)
end
local playerToTeleportName = arguments[1]
local playerToTeleportToName = arguments[2]
if playerToTeleportName and playerToTeleportToName then
local plrToTP = findPlayer(playerToTeleportName)
local plrToTPTo = findPlayer(playerToTeleportToName)
if plrToTP and plrToTPTo then
plrToTP.Character.HumanoidRootPart.CFrame = plrToTPTo.Character.CFrame.HumanoidRootPart
print("Successfully moved")
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message, recipient)
message = string.lower(message)
local splitString = message:split(" ") -- ("/tp", "Alvin" ,"Bob")
local slashCommand = splitString[1] -- "tp"
local cmd = slashCommand:split(prefix) -- ("/" "tp")
local cmdName = cmd[2]
if commands[cmdName] then
local arguments = {} -- Contain the next split parts of the message (e.g Alvin_Blox, DrRaffleBerry)
for i = 2, #splitString, 1 do
table.insert(arguments,splitString[i])
end
commands[cmdName](player, arguments) -- Fired our TP function
end
end)
end)’
