Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Teleporting Function Works Only Once?

Asked by 4 years ago

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

01local Part = script.Parent
02 
03 
04Part.Touched:Connect(function(hit)
05    local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
06    if Player ~= nil then
07        local tele = game:GetService("TeleportService")
08        local gameID = 5791125484
09        if Player.leaderstats.Tickets.Value >=1 then
10            local gui = script.Parent.TPmessage
11            gui:Clone()
12            gui.Parent = Player.PlayerGui
13            Player.leaderstats.Tickets.Value = Player.leaderstats.Tickets.Value - 1
14            tele:Teleport(gameID, Player)  
15        end
16    end
17end)

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

0
Ok so I found out the error, it is getting rid of the GUI even though I clone it... SooGloezNoob 45 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

instead of doing

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

do

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

Ad

Answer this question