I am trying to make a part that has a SurfaceGui, which has a TextButton on it. The part is located in ReplicatedStorage and will be cloned to the workspace, so I try using .Activated with the TextButton but it doesn’t seem to work. (I run the code from StarterGui using a local script.). So after that, I tried putting SurfaceGui into the StarterGui and use Adornee to stick it to the part, but when cloned the Gui no longer stick to the part when cloned. (The ZIndex of the text buttons are also the highest in SurfaceGui). How do I fix this?
Here we go, i changed it, does it work? also i would suggest you to add a script as a child to every text button like TextButton.script and add the button code into it
You are connecting a function to the same event 4 times. You should rename the text buttons before cloning them into the frame.
local Part1 = game.ReplicatedStorage:WaitForChild(“Folder”).Part1.SurfaceGui
local Cloned = Part1:Clone()
Cloned.Parent = game.Workspace --PARENT IT TO A PART
local frame = Cloned.MainBoard.ButtonList.Frame
frame.TextButton1.MouseButton1Click:Connect(function()
print(“Hi”)
end)
frame.TextButton2.MouseButton1Click:Connect(function()
print(“Hi”)
end)
frame.TextButton3.MouseButton1Click:Connect(function()
print(“Hi”)
end)
frame.TextButton4.MouseButton1Click:Connect(function()
print(“Hi”)
end)