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

ClickDetector Running a LocalScript for a Gui?

Asked by 6 years ago

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

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

LocalScripts cannot be used in the workspace. And don't use LocalPlayerfor 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!

0
I also remember you asking this before... why did you ask the same question? PyccknnXakep 1225 — 6y
0
I seem to have misunderstood the first time, but I finally understand now and I've got it to work. Thanks. aquadrious 53 — 6y
0
No problem. PyccknnXakep 1225 — 6y
Ad

Answer this question