Ive tried all i have to my knowledge but it doesnt work pls help
place this in a local script as a child of the text button.
this should work, you can only get click detection of a gui if the script is a child of it, and you have to use the humanoid root part or torso of the player to teleport them.
local teleportPart = workspace:WaitForChild("TeleportPart") local textButton = script.Parent local player = game:GetService("Players").LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") local torso = character:FindFirstChild("Torso") textButton.OnMouseClick:Connect(function() if humanoidRootPart then humanoidRootPart.CFrame = CFrame.new(teleportPart.CFrame) end if torso then humanoidRootPart.CFrame = CFrame.new(teleportPart.CFrame) end end)
local teleportPlace = Vector3.new(0,0,0) local text = script.Parent local randomplayer = math.random(1,#game.Players:GetPlayers) local randomplrHRP = randomplayer:WaitForChild("HumanoidRootPart") debounce = false if text.MouseButton1Click then debounce = true print("The random player is...".. randomplayer "!") print("Teleporting".. randomplayer .."...") if randomplayer then randomplrHRP.Position = teleportPlace print("Success teleported".. randomplayer.. "to the teleportPlace's position!") else error("randomplayer was a nil value.") end debounce = false end
Btw, make the game as R15.
Second, make the teleportPlace's position to the position that you want!
~~ How this script works ~~
We don't need to discuss about what we localed cause its useless to know about though.
if text.MouseButton1Click then
this makes the code that sandwiched inside if text.MouseButton1Click then
fires whenever people click the button.
Btw, if the print code is bugging, just mark them as note or delete them lol... They're useless and do nothing else prints what they did in the output.
Later, if we localed the randomplayer, and then pressed the button, they will sensor about are the randomplayer is in the game, if it doesn't, it put out an error.
In a nutshell, pressed the button, get randomplayer and makes the randomplayer's humanoid root part to the teleportPlace's position!
If you don't know how to make the game to R15, see the below!
And if this helped you, mark this as the answer, if doesn't help or need more explains, comment below down too! thanks :)
Go to my video to see how to make the game r15! Btw subscribe pls