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

Teleporting Function Works Only Once?

A simple teleporting touch function HOWEVER it only works once, when another player touches it. It doesn't teleport them...?

local Part = script.Parent


Part.Touched:Connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if Player ~= nil then
		local tele = game:GetService("TeleportService")
		local gameID = 5791125484 
		if Player.leaderstats.Tickets.Value >=1 then
			local gui = script.Parent.TPmessage
			gui:Clone()
			gui.Parent = Player.PlayerGui
			Player.leaderstats.Tickets.Value = Player.leaderstats.Tickets.Value - 1
			tele:Teleport(gameID, Player)	
		end
	end
end)

need help ASAP considering this is the main function of the game!

1 comment

0

Ok so I found out the error, it is getting rid of the GUI even though I clone it...

1 answer

instead of doing

local gui = script.Parent.TPmessage
gui:Clone()

do

local gui = script.Parent.TPmessage:Clone()

When you clone, you are just cloning the GUI, whatever you do to that variable you set is not to the clone, but to the original.

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