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

This script only works once, although it should be working more than once?

Asked by 5 years ago
Edited 5 years ago

This script basically places the 'TeleportGUI' in the player when they touch the block, as long as they dont already have one in them. This always works the first time around, but never again. Is there a flaw?

local debounce = false



function getPlayer(humanoid) 

    local players = game.Players:children() 

    for i = 1, #players do 

    if players[i].Character.Humanoid == humanoid then return players[i] end 

end 

    return nil 

end 



function onTouch(part) 



    local human = part.Parent:findFirstChild("Humanoid") 

    if (human ~= nil) and debounce == false then



    debounce = true



    local player = getPlayer(human) 



    if (player == nil) then return end 



    user = game.Players:findFirstChild(human.Parent.Name)

    if not player.PlayerGui:FindFirstChild("TeleportGUI") then
        script.Parent.TeleportGUI:clone().Parent = player.PlayerGui
end






    wait(2)

    else

    wait(2)

    debounce = false

end

end

Also, the TeleportGUI gets destroyed after the player uses it. Heres the script in the TeleportGUI

function Click()

local Player = game:GetService("Players").LocalPlayer

local Character = Player.Character

local HRP = Character.HumanoidRootPart


HRP.CFrame = CFrame.new(workspace.forestbrick.Position)

Player.leaderstats.Attempts.Value = 0

script.Parent.Parent.Parent:Destroy()

end

script.Parent.MouseButton1Down:connect(Click)
0
please indent your code theking48989987 2147 — 5y
0
there you go Octocentillion 15 — 5y
0
Well i am sorry that i cant answer your question but you have a Secruity issue a hacker could insert a local script that give them the power to open/copy the GUI on their command EnderPowerHD 98 — 5y

Answer this question