Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hmmm...A Timer GUI? I need teleportation assistance

So, I have a GUI for a timer for the Ninja Warrior game I'm making right now. Here's the script:

part = script.Parent
Time = script.Parent.Time
Gui = game.StarterGui.ScreenGui.TextLabel
bool = true

function onTouched()
	if bool == false then return end
	bool = false
	if part:FindFirstChild("Humanoid") ~= nil then
		Time.Value = 90
		Gui.Text = "90"
		for i = 1,90 do
			Time.Value = Time.Value - 1
			Gui.Text = Time.Value
			wait(1)
			if Time.Value == 0 or if workspace["Stage 1"].Water:FindFirstChild("Humanoid") ~= nil then
			Gui.Text = "Failure!"
			part.Parent.Torso:BreakJoints()
			wait(8)
			Gui.Text = "90"
			if workspace["Stage 1"].Clear:FindFirstChild("Humanoid") ~= nil then
				if Time.Value > 0 then
					Gui.Text = "Clear!"
					part.Parent.Torso:BreakJoints()
					wait(10)
					Gui.Text = "90"
				end
			end
		end	
	end
	wait(10)
	bool = true
end

My main question is that how do I make it teleport to a certain place without killing the Humanoid of the Player? Would I use "spawn"?

1 answer

✓ Accepted answer

You shouldn't use Spawn(), Spawn is a built - in function used for running code in a separate thread (script).

Use MoveTo, or cframe the HumanoidRootPart.

-- This script can teleport all the players to 0,0,0

for _,v in pairs(game.Players:GetPlayers()) do
       v.Character:MoveTo(Vector3.new())
end

On line 11, I see you've attempted to change the text of the players' gui on the screen, that's not the way to do it. The descendants of the players' PlayerGui is what the player sees on their screen.

If you're not using FilteringEnabled, use this to change the text.

function changeText(text)
       for _,v in pairs(game.Players:GetPlayers()) do
              v.PlayerGui.ScreenGui.TextLabel.Text = text
       end
end

--Example

changeText('Test')

This discussion is preserved as it was. New answers, comments, and votes are closed.