Hello,
I want to make this GUI visible again (right now it’s visible as soon as the player joins the game) when a part is touched and I have this LocalScript:
local part = game.Workspace.TouchPart;
local plr = game.Players.LocalPlayer;
local ui = script.Parent;
part.Touched:Connect(function(hit)
if plr.Character ~= nil and hit.Parent == plr.Character then
ui.Visible = true;
end
end)
and this is the structure:
LocalScript content (the one inside UIGradient) in case it’s needed:
Okay and do they close the Ui, if they don’t and its alwaysvisible and on their screen, what is the need to make something that is already visible, visible with the part?
Okay so, the Ui isn’t showing up, because its transparent. Trying to turn visible true again won’t do anything because it is still visible its just transparent. Personally after turning it transparent, I’d turn it invisible, and have it so that when they touch the part it resets the Ui to its original state.
How would I fix that in this script? I haven’t understood really well how to do it
local part = game.Workspace.TouchPart;
local plr = game.Players.LocalPlayer;
local ui = script.Parent;
part.Touched:Connect(function(hit)
if plr.Character ~= nil and hit.Parent == plr.Character then
ui.Visible = true;
end
end)
Okay so currently, your UIGradient script is just turning your UI transparent, so in the properties of your UI Visible = true, however the Transparency of your Frame(Frame that is the child of the ScreenGui) is equal to 1, meaning that your ScreenGui is Visible, however the Frame is not.
What you need to do is after it’s transparent, remove its visibility, and then turn the background back to 0. That’s the simple way to fix it.
local part = game.Workspace.TouchPart
local plr = game.Players.LocalPlayer
local ui = script.Parent
part.Touched:Connect(function()
ui.Visible = true
end)
--- if you want to check the player
part.Touched:Connect(function(hit)
if plr.Character ~= nil and hit.Parent.Name == plr.Name then
ui.Visible = true
end
end)
I don’t know what the “;” does but I’ve never seen nor used it before.