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 4 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 — 4y

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

01function visible(player.PlayerGui.menu.Frame.Visible = true)
02    function invisible(player.PlayerGui.menu.Frame.Visible = false)
03end
04local player = game.Players.LocalPlayer
05 
06    script.Parent.MouseButton1Click:Connect(function()
07        invisible
08    end)
09    wait(0.1)
10    if player.PlayerGui.menu.Frame.Visible = false then
11        function(visible)
12    end
13 
14end)

**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:

01local open = false -- your gaming variable
02 
03thetpbutton.MouseButton1Click:Connect(function() -- when tp button is clicked
04    if open == true then -- checks if the ui is open
05        open = false -- sets it to false so it closes and get tp
06        print("you clicked tp button or close button and closes the ui") -- prints cos me lazy :)
07        -- more codddE
08    end
09end)
10 
11yourmenubutton.MouseButton1Click:Connect(function() -- opens the button visibility
12    if open == false then -- checks if nope
13        open = true -- goes true, why not?
14 
15        print("OPENS UP THE BUTTON")
View all 22 lines...
0
put it in one local script only acediamondn123 147 — 3y

Answer this question