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

How to display GUI when clicking on brick?

I inserted a local script in the brick. Am I supposed to use a normal script? I also used the code in the normal script and it doesn't work either.

local dialogue = game.StarterGui.Dialogue1

script.Parent.ClickDetector.MouseClick:Connect(function()
	wait(1)
	dialogue.T1.Visible = true
	wait(3)
	dialogue.T1.Visible = false
	wait(1)
	dialogue.T2.Visible = true
	wait(3)
	dialogue.T2.Visible = false
end)

2 answers

✓ Accepted answer

For this you have to use remote event. Note that it should be a client event.

First Part: Make a normal script parented to part in workspace.

local CD = script.Parent.ClickDetector
local toggle = false

CD.MouseClick:Connect(function(player)
	if toggle == false then
		toggle = true
		game.ReplicatedStorage.RemoteEvent:FireClient(player, toggle)
	elseif toggle == true then
		toggle = false
		game.ReplicatedStorage.RemoteEvent:FireClient(player, toggle)
	
	end
	
	
	
end)

Now Second Part: Make a local script parented to ScreenGui in StarterGui.

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(toggle)
	if toggle == true then
		script.Parent.Frame.Visible = true
		
	else
		script.Parent.Frame.Visible = false
		
	end
	
	
end)

Hope this works for you as it is doing for me!

3 comments

0

it says RemoteEvent is not a valid member of ReplicatedStorage

0

so u have to insert a RemoteEvent in ReplicatedStorage

0

oh

Local Script

local dialogue = game.Players.LocalPlayer.PlayerGui. Dialogue1

script.Parent.ClickDetector.MouseClick:Connect(function()
    wait(1)
    dialogue.T1.Visible = true
    wait(3)
    dialogue.T1.Visible = false
    wait(1)
    dialogue.T2.Visible = true
    wait(3)
    dialogue.T2.Visible = false
end)

1 comment

0

Doesn't work

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