Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
oilsauce 196
6 years ago
Edited 6 years ago

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.

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 natonator63 29 — 6y
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. oilsauce 196 — 6y
Ad
Log in to vote
0
Answered by
angeI1001 123
6 years ago

You can use a RemoteEvent for that, which you can find here: https://www.robloxdev.com/api-reference/class/RemoteEvent

Answer this question