This implies to me the issue is with whatever code makes it disappear. Seeming that the close function either makes another part invisible that this doesn’t handle, or just destroys the gui.
I would recommend you to change the UI visibility on a local script
rather then a server script
.
You could do all of this through a Remote Event
.
Example
Server Script:
local brick = game.Workspace.OpenGUI
local RemoteEvent = game.ReplicatedStorage.RemoteEvent --place your remote event in ReplicatedStorage and reference it here
brick.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
RemoteEvent:FireClient()
end
end)
Local Script:
local localPlayer = game.Players.LocalPlayer
local PlayerGui = localPlayer.PlayerGui
local OpenGui = PlayerGui.OpenGui --reference your gui here
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent.OnClientEvent:Connect(function()
OpenGui.Visible = true
end)
No, the part and gui both are there, its just something with the script. I even tried something like this:
script.Parent.touched:Connect(function(hit)
Local plr = game.Players.GetPlayerFromCharacter(hit.parent)
If plr then
plr.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Frame").Visible = true
end
end)
I will try both and this and share the results
Can you include the snippet of code that handles closing your gui? As far as I can tell, the opening part should work. So the only potential issue I can see is that closing it is changing a state that the opening script isn’t handling correctly.
I agree this is why I was asking where the Visible was set to false. Sometimes people move the Gui to slide it off the screen or set the background transparent instead which would make the Visible useless after the first time.
Possible one is a local script and the other is a server script so it doesn’t update when the local script makes changes.
this is the close button script:
script.Parent.MouseButton1Click:Connect(function()
local frame = script.Parent.Parent
if frame.Visible == true then
frame.Visible = false
else
frame.Visible = false
end
end)
Are both of the scripts LocalScripts?
yes both of the scripts and the close button script too are localScripts
this doesn’t seem to be working
same issue (word limit_____________)
Hmm… Yeah I’m not sure, the last thing I can think of is maybe script.Parent.Parent of the close script is not equal to script.Parent of the open script. Though I don’t think that’s particularly likely.
Can you show a picture of your Explorer window with your Gui layout(if it differs that is)? I replicated what I assume is your layout, StarterGui, ScreenGui under StarterGui, Frame under ScreenGui along with the LocalScript for the part Touched event, Button under Frame with LocalScript to make invisible and it works with no problems. I did change the close button a bit because there is no need to have an IF statement and put the same code in both the true and false case so it was just:
script.Parent.MouseButton1Click:Connect(function()
local frame = script.Parent.Parent
frame.Visible = false
end)
Here is my setup:
If you do have this exact layout all I can suggest is close and restart Roblox Studio.
you can’t put your gui inside of your part
try getting the player name from the hit and then make the gui visible from the playergui
It would help if you could record and post the video of this issue. Also any gui should be placed preferably in PlayerGui (StarterGui).
Well Guys I Made It Work, I Didn’t Realised The Script In Part Was A ServerScript And Hence It Was Glitching, But Still I Don’t Get Why How Did The ServerScript Worked Once Then Broke Even Though I Am Not Using Exact Same Code In A LocalScript. Is This A Bug Or Something?
I Made A New LocalScript In StaterGUI As A Client That Handles Close Button And Part OpeningGUI On Touch
You don’t need to do allat.
frame.Visible = not frame.Visible
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.