Hello!
I’m making a function where it disables every LocalScript I inserted in a player’s PlayerGui. I was wondering, how do I add the player variable to my function?
Hello!
I’m making a function where it disables every LocalScript I inserted in a player’s PlayerGui. I was wondering, how do I add the player variable to my function?
Unrelated, but this is a bad practice.
What exactly is going on? At what point do the scripts need to be disabled?
Once someone presses a button in my gui, it fires a remote, and that remote adds a local script. Let’s call that local script “SecondLocalScript”. Basically, for “SecondLocalScript” to work, every other local scripts have to be disabled. Making a function that disables every local script would make it way easier.
Here’s a function I tried to make work.
function DisableGui()
local Children = Player.PlayerGui.ColorFolders:GetDescendants()
for i,v in pairs(Children) do
if v:isA("LocalScript") then
v.Disabled = true
end
end
end
When a remote is fired, the first argument the server gets is which player fired the remote.
local Remote = somePathToRemote
local function OnServerEvent(PlayerWhoFired)
-- stuff
end
Remote.OnServerEvent:Connect(OnServerEvent)
I know how remotes work, I was just wondering if there was a way to add the player who fired the remote or make a local player for a server script’s function
I’m confused.
Then use the player object that the remote gives you. I mentioned this in my 2nd reply. Other than that, I’m pretty confused as to what you’re asking.
I’ll just not use a function and do everything in the remote, thank you tho!