Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to activate a gui when you click on a brick/w clickdetector?

its a localscript also its in starterplayerscripts

local GUI = UI local Button = GUI.Button
local player = game.Workspace.localPlayer
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")
mouse = player:GetMouse()
local idoit = game.Workspace.CHING.ClickDetector
UI = game.StarterGui.KiKidied.tooxtbutton --idk why i named it that no judge

idoit.MouseButton1Click:Connect(function()

local frame = GUI.Frame

Button.MouseButton1Click:Connect(function() frame.Visible = true end)
end)

2 answers

If you want a Frame to be visible when you click on a ClickDetector, all you have to fix is

idoit.MouseButton1Click:Connect(function()
 
local frame = GUI.Frame
frame.Visible = true -- The frame becomes visible when 'idoit' (the ClickDetector) is clicked.
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.

idoit.MouseButton1Click:Connect(function()
 
local frame = GUI.Frame
frame.Visible = true -- The frame becomes visible when 'idoit' (the ClickDetector) is clicked.
end)


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.
local Button = GUI.Button
local player = game.Workspace.LocalPlayer
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")
mouse = player:GetMouse()
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.

2 comments

0

it tells me"infinite yield possible" and "localscript is not a valid member of players" also here is the scriptlocal player = game.Workspace.localPlayer local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:FindFirstChild("ButtonClick") mouse = player:GetMouse() local idoit = game.Workspace.CHING.ClickDetector UI = game.StarterGui.KiKidied.Frame --idk why i named it tha

0

Crap, I misspelled it. It's LocalPlayer, and if it gives you an 'infinite yield possible' error, it means that it doesn't have the object in the desired place.

This discussion is preserved as it was. New answers, comments, and votes are closed.