Hi guys, I have problem with Click Detector. I want to make when you click part the screengui frame label will be visible.
Properties:
Code:
--Variable--
local Open = game.StarterGui.ScreenGui.MainFrame.Open
local Closed = game.StarterGui.ScreenGui.MainFrame.Closed
local MartialLaw = game.StarterGui.ScreenGui.MainFrame.MartialLaw
--Main Code--
script.Parent.ClickDetector.MouseClick:connect(function()
game.Players.LocalPlayer.PlayerGui.ScreenGui.MainFrame.Open.Visible = true
end)
First of all, that error didn’t originate from this Script - take a look a the stack trace and you’ll see it comes from a Plugin named GoodPlugin, with a Script named Plugin.
Secondly, StarterGui’s contents are cloned locally on join and the LocalPlayer doesn’t exist in a Script (that runs on the server) because the LocalPlayer is whom the LocalScript is running for.
You’ll want to integrate a RemoteEvent into here that a LocalScript Connects onto it’s OnClientEvent to make the Open TextLabel Visible. Then you’ll want to utilise the Player parameter from the MouseClick to FireClient the RemoteEvent.
Players.LocalPlayer is a variable only accessable by client (local) scripts. You could make a LocalScript in the ScreenGui, give it a reference to the ClickDetector (workspace.Open.ClickDetector) and a reference to the TextLabel (script.Parent.MainFrame.Open). Attach a MouseClick event to the detector and you should be good to go.
It’s usually a bad idea to handle client sided effects on the server. It causes more data to be transmitted over the client server boundary + all the issues that come with networking. In this case, it would be a better idea to handle this from a LocalScript because it’s just as easy as handling it from a server script.