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

ClickDetector Running a LocalScript for a Gui?

This one is a bit of a follow-up from my previous question. I've got a script that makes a Frame with Text appear when a block is clicked (locally, by the way) but for a ClickDetector, I'm pretty sure you can only use a script. So how do I make the script, when noticed the click from the ClickDetector, run the LocalScript? Here's my current Server Script:

local Gui = game.Players.LocalPlayer.PlayerGui.TextInteractions.ComputerText
	
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	function onClicked ()
	Gui.Visible = true
	wait(3)
	Gui.Visible = false
end
end)

Please point out if things are incorrectly written, by the way! I'm newer to scripting.

1 answer

✓ Accepted answer

LocalScripts cannot be used in the workspace. And don't use LocalPlayer for this method. Also, do not use another function within the mouseclick function, it's just a waste of time.

script.Parent.ClickDetector.MouseClick:Connect(function(player)
local gui = player.PlayerGui.ScreenGui.ComputerText --wherever it is
gui.Visible = true
wait(3)
gui.Visible = false
end)

Please accept my answer if this helped!

3 comments

0

I also remember you asking this before... why did you ask the same question?

0

I seem to have misunderstood the first time, but I finally understand now and I've got it to work. Thanks.

0

No problem.

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