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
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
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.
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.