Unable to cast string to CoordinateFrame

  1. I’m trying to make a teleport character script

  2. It won’t teleport the player
    image

  3. I have tried searching videos on how to fix it but none of them helped

Here is the code:

-- script.ClassName = "Script"

local x = 204.1
local y = 122.4
local z = 89.3

local xyz = tostring(x..","..y..","..z)
local cxy = (x..34/x..36/x..34/x..36/x..34/x.."36"..tostring(xyz))

local axxyz = cxy
local gr = axxyz
local grb = gr
local xyt = grb
local abc = xyt
local xdf = abc
local mla = xdf
local mal = mla
local kei = mal
local nkk = kei
local prn = nkk
local pmkk = pm
local nrts = pmkk
local nqra = nrts
local mass = nqra*y
local gra = mass/20.5
local pra = gra*3.14
local lrq = pra/19.25
local gta = lrq/20
local p = gta

local prt = script.Parent
local ar = prt*2
local mp = ar/2

function Touched(hitby)
	if hitby.Parent.ClassName == "Model" then
		if hitby.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:GetPlayerFromCharacter(hitby.Parent)
			if plr then
				hitby.Parent:SetPrimaryPartCFrame(tostring(cxy,p))
				hitby.Parent.HumanoidRootPart.CFrame = CFrame.new(p or xyz)
			end
		end
	end
end

mp.Touched:Connect(Touched)

You are passing in a type string instead of a type CFrame inside of the SetPrimaryPartCFrame.

Is all of that really necessary? Just do

function Touched(hitby)
	if hitby.Parent.ClassName == "Model" then
		if hitby.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:GetPlayerFromCharacter(hitby.Parent)
			if plr then
				hitby.Parent:SetPrimaryPartCFrame(CFrame.new(x, y, z))
			end
		end
	end
end

prt.Touched:Connect(Touched)

Still won’t work⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

image

I don’t know if you are trolling, but that is extremely unnecessary to do that. Because my answer based on what you posted before editing in more bloat works fine on my machine.

What is your new code after you edited it?

-- script.ClassName = "Script"

local x = i:204.1
local y = i:122.4
local z = i:89.3

local xyz = tostring(x..","..y..","..z)
local cxy = (x..34/x..36/x..34/x..36/x..34/x.."36"..tostring(xyz))

local axxyz = cxy
local gr = axxyz
local grb = gr
local xyt = grb
local abc = xyt
local xdf = abc
local mla = xdf
local mal = mla
local kei = mal
local nkk = kei
local prn = nkk
local pmkk = pm
local nrts = pmkk
local nqra = nrts
local mass = nqra*y
local gra = mass/20.5
local pra = gra*3.14
local lrq = pra/19.25
local gta = lrq/20
local p = gta

local prt = script.Parent
local ar = prt*2
local mp = ar/2

function Touched(hitby)
	if hitby.Parent.ClassName == "Model" then
		if hitby.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:GetPlayerFromCharacter(hitby.Parent)
			if plr then
				hitby.Parent:SetPrimaryPartCFrame(tostring(cxy,p))
				hitby.Parent.HumanoidRootPart.CFrame = CFrame.new(p or xyz)
			end
		end
	end
end

mp.Touched:Connect(Touched)

This script is the same as the last one. What did you change?


local i = in pairs(args:lua)

local x = i:204.1
local y = i:122.4
local z = i:89.3

local xyz = tostring(x..","..y..","..z)
local cxy = (x..34/x..36/x..34/x..36/x..34/x.."36"..tostring(xyz))

local axxyz = cxy
local gr = axxyz
local grb = gr
local xyt = grb
local abc = xyt
local xdf = abc
local mla = xdf
local mal = mla
local kei = mal
local nkk = kei
local prn = nkk
local pmkk = pm
local nrts = pmkk
local nqra = nrts
local mass = nqra*y
local gra = mass/20.5
local pra = gra*3.14
local lrq = pra/19.25
local gta = lrq/20
local p = gta

local prt = script.Parent
local ar = prt*2
local mp = ar/2

function Touched(hitby)
	if hitby.Parent.ClassName == "Model" then
		if hitby.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:GetPlayerFromCharacter(hitby.Parent)
			if plr then
				hitby.Parent:SetPrimaryPartCFrame(tostring(cxy,p))
				hitby.Parent.HumanoidRootPart.CFrame = CFrame.new(p or xyz)
			end
		end
	end
end

mp.Touched:Connect(Touched)