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

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!

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

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.

Ad

Answer this question