I’m trying to teleport player to a certain place but it just changes position of the bodypart which is given in there. (I tried HumanoidRootPart but it didn’t worked)
function onButtonTouched(player)
--[[Appearance]]--
Button.BrickColor = BrickColor.new("Really red")
local charClone = Character:Clone()
charClone.Name = player.Name
player.Character = charClone
local rootPart = charClone:FindFirstChild("HumanoidRootPart") or charClone:FindFirstChild("Torso")
local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso")
if rootPart and plrRoot then
rootPart.CFrame = plrRoot.CFrame
end
charClone.Parent = workspace
local number = math.random(0, #Spawns)
local chosenSpawn = Spawns[number]
rootPart.Position = chosenSpawn.Position
task.wait(2)
Button.BrickColor = BrickColor.new("Sea green")
end
There is no errors.