Help with local scripts and where they can access

`local plr = game.Players.LocalPlayer

script.Parent.Equipped:connect(function()
if plr:GetRankInGroup(3912330) >= 10 then
plr:FindFirstChild(“PlayerGui”)
if plr.PlayerGui:FindFirstChild(“Securitymain”) then
plr.PlayerGui.securityMain.Enabled = true
end
end
end)

script.Parent.Unequipped:connect(function()
if plr:FindFirstChild(“PlayerGui”) then
if plr.PlayerGui:FindFirstChild(“securityMain”) then
plr.PlayerGui.securityMain.Enabled = false
end
end
end)`
(It won’t work and no error was outputted)

I was wondering if someone can link or tell me where locals can access, Thanks.

2 Likes

Check the wiki: http://wiki.roblox.com/index.php?title=API:Class/LocalScript

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack, such as a child of a Tool
  • A Player’s Character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts
  • The ReplicatedFirst service

(assuming you’re using FE:)
The places they can access are only places that have been replicated to and/or created by that particular client, i.e anything in replicated storage, objects anywhere created by the client etc. The client can access technically anything in the whole game, but nothing will replicate to the server (and other clients) unless the server carries out the action needed. For more detailed and accurate information regarding filtering enabled, check the wiki: http://wiki.roblox.com/index.php?title=Building_Games_with_Experimental_Mode_Off

For tools specifically, you can place a localscript inside the tool, as long as the tool is parented to the character, and it will run correctly. Make sure the script you are running is a localscript parented to the tool, and you should be good to go.

A problem i’ve noticed specifically in your code is:

Check the capitalisation, is the name of the GUI “Securitymain” or “securityMain”?
This is most likely to be your problem if nothing else.

4 Likes