How to Make gui teleporter !?

Hello ! I’m not super adviced and not too short at roblox development but everybody have problems with this sometimes . So when I made my game and I needed to make battle royal gui that will teleport players to other island (Not other place) , I did a mistake . And now it doesn’t work .
Help me please !

This is a code from button that must teleport player :point_down:

local plz = game.Players.LocalPlayer
local fuf = script.Parent.Parent 
local teleparts = {
workspace.Telepart1, workspace.Telepart2, workspace.Telepart3, workspace.Telepart4, workspace.Telepart5
}

script.Parent.MouseButton1Click:Connect(function() 
	plz.Character.Torso.CFrame = teleparts[math.random(1, #teleparts)].CFrame
	print("Connected to button")
	wait(0.2)
	fuf.Visible = false
	end

also I made it LocalScript just for information .

3 Likes

Are there any errors? …

2 Likes

please close the Connect function with a bracket on the last line

2 Likes

Ur script works for only R6 tho

1 Like

I suggest using HumanoidRootPart instead of Torso.

3 Likes

I examined the code a bit and got it working by a few simple fixes.

Basically you only have to change the torso to HumanoidRootPart and delete the .CFrame at the end of the teleport line and replace it with this. CFrame.new(teleparts[math.random(1, #teleparts)]).
lastly, I went and added the Position property at the end of every part in the teleparts table like this workspace.Telepart1.Position. Also there should be a bracket after the end on the last line.

3 Likes

Why it is working only for R6 ?

Because R15 does not have a Torso, instead it has UpperTorso and LowerTorso. I would suggest using the HumanoidRootPart like @Crrustyy said since it is in both R6 and R15.

2 Likes

This is really good correction but it still doesn’t work
it’s my present code

local plz = game.Players.LocalPlayer
local fuf = script.Parent.Parent 
local teleparts = {
workspace.Telepart1.Position, workspace.Telepart2.Position, workspace.Telepart3.Position, workspace.Telepart4.Position, workspace.Telepart5.Position
}

script.Parent.MouseButton1Click:Connect(function() 
	plz.Character.HoomanoidRootPart.CFrame = CFrame.new(teleparts[math.random(1,#teleparts)])
	print("Connected to button")
	wait(0.2)
	fuf.Enabled = false
end)

What I can change ?

Why did you name HumanoidRootPart to HoomanoidRootPart? Thats really odd.

1 Like

Huh , you right . It’s most stupid mistake that I ever made ! (No)

1 Like