its a localscript also its in starterplayerscripts
01 | local GUI = UI local Button = GUI.Button |
02 | local player = game.Workspace.localPlayer |
03 | local repStorage = game:GetService( "ReplicatedStorage" ) |
04 | local remote = repStorage:FindFirstChild( "ButtonClick" ) |
05 | mouse = player:GetMouse() |
06 | local idoit = game.Workspace.CHING.ClickDetector |
07 | UI = game.StarterGui.KiKidied.tooxtbutton --idk why i named it that no judge |
08 |
09 | idoit.MouseButton 1 Click:Connect( function () |
10 |
11 | local frame = GUI.Frame |
12 |
13 | Button.MouseButton 1 Click:Connect( function () frame.Visible = true end ) |
14 | end ) |
If you want a Frame to be visible when you click on a ClickDetector, all you have to fix is
1 | idoit.MouseButton 1 Click:Connect( function () |
2 |
3 | local frame = GUI.Frame |
4 | frame.Visible = true -- The frame becomes visible when 'idoit' (the ClickDetector) is clicked. |
5 | end ) |
Also, you should probably use the WaitForChild() function when you're getting something from the StarterGui, or other places. It'll wait until the thing you want exists.
1 | idoit.MouseButton 1 Click:Connect( function () |
2 |
3 | local frame = GUI.Frame |
4 | frame.Visible = true -- The frame becomes visible when 'idoit' (the ClickDetector) is clicked. |
5 | end ) |
1 | local GUI = game.StarterGui:WaitForChild( "KiKidied" ):WaitForChild( "tooxtbutton" ) -- this will throw a warning if there is no such object as 'KiKidied' in StarterGui, or if there is no such object as 'tooxtbutton' in KiKidied. |
2 | local Button = GUI.Button |
3 | local player = game.Workspace.LocalPlayer |
4 | local repStorage = game:GetService( "ReplicatedStorage" ) |
5 | local remote = repStorage:FindFirstChild( "ButtonClick" ) |
6 | mouse = player:GetMouse() |
7 | local idoit = game.Workspace.CHING.ClickDetector |
You shouldn't really put two WaitForChild() functions in in a row, but to not modify your script too much, I made the script wait until there is an object named 'KiKidied' in StarterGui. Then it'll wait until there is an object named 'tooxtbutton' in 'KiKidied'.
I hope this helped, I was a bit sleepy when I wrote this, you're free to ask any questions.
You can use a RemoteEvent for that, which you can find here: https://www.robloxdev.com/api-reference/class/RemoteEvent