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

My GUI's are not working correctly. Might be some of my scripts?

Asked by 3 years ago

So what my scripts do is when they click the menu, it brings up a gui which shows them a gui which if they click it it will teleport them to a place and make the gui disappear. Here are the scripts below. the problem is that when they join, for some reason it flashes the gui when i click it, what i mean by that is it shows and does not show and shows agian. Another problem is that after they click the teliport button, if they click it agian, the menu gui does not show agian.


local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function() player.PlayerGui.menu.Frame.Visible = true

end)


This is where when they click the button, they show a gui.


wait(1) player = game.Players.LocalPlayer button = script.Parent local debounce = false

function teleport() if not debounce then debounce = true LowerTorso = player.Character.LowerTorso LowerTorso.CFrame = game.Workspace.SpawnLocation.CFrame end end

button.MouseButton1Click:Connect(teleport) while true do wait() debounce = false wait(1) if true then script.Parent.Parent.Visible = false end

end

this is the script where is they click another button, it teliports them somewhere


script.Parent.MouseButton1Click:Connect(function(click) script.Parent.Parent:Destroy()

end)

this is where if they click the same button as the teliport, it will teliport them while also taking away the gui.

I am new to scripting, i can make easy types of scripts, so thats why it might look like a easy fix but not for me.

0
Put your script in a code block to make it more readable. AntoninFearless 622 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

This solution worked for me but I don't know if it will work for you, for me it has some minor errors but i fixed the part where it turns on and off for you. no homo

function visible(player.PlayerGui.menu.Frame.Visible = true)
    function invisible(player.PlayerGui.menu.Frame.Visible = false)
end
local player = game.Players.LocalPlayer

    script.Parent.MouseButton1Click:Connect(function() 
        invisible
    end)
    wait(0.1)
    if player.PlayerGui.menu.Frame.Visible = false then
        function(visible)
    end

end)

**buuurrrrrrrrrrrrrrrp

Ad
Log in to vote
0
Answered by 3 years ago

use a variable to know if player clicked the close or on and you can use that when player clicked teleport then it will go off right?

Simple example:

local open = false -- your gaming variable

thetpbutton.MouseButton1Click:Connect(function() -- when tp button is clicked
    if open == true then -- checks if the ui is open
        open = false -- sets it to false so it closes and get tp
        print("you clicked tp button or close button and closes the ui") -- prints cos me lazy :)
        -- more codddE
    end
end)

yourmenubutton.MouseButton1Click:Connect(function() -- opens the button visibility
    if open == false then -- checks if nope
        open = true -- goes true, why not?

        print("OPENS UP THE BUTTON")
        -- more code man
    else
        open = false
        print("CLOSeS IT UP")
        -- more code
    end
end)
0
put it in one local script only acediamondn123 147 — 3y

Answer this question