Right now im trying to create a script when you click on a part/model it will make the GUI visible
BUT im trying to make it so 3 parts/models scattered around the game will show the same GUI
The issue is that only 1 Part works while the other 2 dont make the GUI visible
Ive tried looking for solutions and making a new script in server script to see if it would work. But nothing
My process so far:
Ive created a ScreenGui with a frame and named it and i have a part/model with a click detector.
When i press only one of the models it shows the GUI ive made while the others dont show anything.
heres the code its simple enough to locate the part and to make GUI visible:
(ALL THE PARTS ARE NAMED THE SAME)
local Button = game.Workspace.MenuBlock
local Click = Button.ClickDetector
local Gui = script.Parent.MenuFrame
Click.MouseClick:Connect(function(player)
Gui.Visible = not Gui.Visible
end)
you need to name the parts differently and create seperate mouse click events for each part, or move all the parts into a folder and iterate over the folder, setting up the mouse click listener for each child
example:
local buttonFolder = workspace.Buttons
for _, button in pairs(buttonFolder:GetChildren()) do
button.ClickDetector.MouseClick:Connect(function(player)
Gui.Visible = not Gui.Visible
end)
end