That’s it, that’s the title.
I’m enabling them from my main menu script after it gets destroyed with this:
local scriptsFolder = game.Players.LocalPlayer.Character:WaitForChild("Scripts")
local scripts = scriptsFolder:GetChildren()
-- Few lines down...
for i, v in pairs(scripts) do
if v:IsA("LocalScript") then
v.Enabled = true
end
end
I tried using a separate enabler script:
local SCRIPTS = script.Parent.Scripts:GetChildren()
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
repeat task.wait() until character:FindFirstChild("Humanoid")
local humanoid = character:WaitForChild("Humanoid")
player.CharacterAdded:Connect(function()
for i, v in pairs(SCRIPTS) do
if v:IsA("LocalScript") then
v.Enabled = true
end
end
end)
but this didn’t seem to work. No idea how to fix this.
Here’s an image of the explorer:
I feel like the solution is going to be extremely simple and I’m just blind or overlooking something right in front of me.
Thank you anyways
One thing to point out, I don’t think you need the CharacterAdded event, as well as the player variable, since the script is automatically parented to the character, and would basically rerun when the character respawns. Try removing it and see if that could fix the issue.
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local scripts = character:WaitForChild("Scripts")
for i, v in pairs(scripts:GetChildren()) do
if v:IsA("LocalScript") then
v.Enabled = true
end
end
this brings up an infinite yield in the output Players.Foxxive.PlayerGui.Menu.Buttons.Canvas.MainFrame.Play.Button:WaitForChild("Humanoid")
The old code doesn’t, for some reason
I did, and adjusted the code a little:
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local SCRIPTS = character:WaitForChild("Scripts"):GetChildren()
player.CharacterAdded:Connect(function()
for i, v in pairs(SCRIPTS) do
if v:IsA("LocalScript") then
v.Enabled = true
end
end
end)
The error I gave happened with the script parented to StarterCharacter
It returns an infinite yield which it shouldn’t, I don’t know why it does
Nevermind, I just messed something up lol
It does work, but some of the scripts now only work AFTER I reset. The camera bobbing script is the first one I noticed
The error message you gave says the error occurred from a script in PlayerGui. Or your code is mentioning something in PlayerGui for some reason.
Could you please show your current code in the script parented to StarterCharacterScripts?
I’m not quite sure about this, but maybe it could be something to do with those scripts themselves. Check to see if the scripts are even enabled in-game from the properties tab.
I am not sure if this would work as I haven’t tried this yet, but try converting the LocalScript (that enables all the other scripts) into a Server Script, and paste the code in it.
how would I go about that? As far as I’m aware there is no way to access a player’s scripts through the server. I could be wrong (and I most likely am) but I genuinely have no idea
What I meant was to use a Server Script instead of a LocalScript to enable the other LocalScripts. Make sure to paste the exact same code I have given and that it is parented to StarterCharacterScripts.
Also, maybe add a task.wait() (any amount of seconds) as it may take some time for the scripts to load.[/spoiler]
yes I know what you meant, I’m just unsure how to accomplish it. I’m not experienced with server stuff outside of remotes and basic game systems.
Unless I don’t know what you meant, and to use a server script INSIDE starter character
Okay, I did the latter and used a server script inside of startercharacter, which changed nothing. I added a task.wait above the v.Enabled in the loop for good measure. Again, nothing changed. Same result
local player = game:GetService("Players").LocalPlayer
local humanoid
if player.Character then
humanoid = player.Character:WaitForChild('Humanoid')
for i, v in pairs(player.Character:WaitForChild("Scripts"):GetChildren()) do
if v:IsA("LocalScript") then
v.Enabled = true
end
end
end
player.CharacterAdded:Connect(function()
humanoid = player.Character:WaitForChild('Humanoid')
for i, v in pairs(player.Character:WaitForChild("Scripts"):GetChildren()) do
if v:IsA("LocalScript") then
v.Enabled = true
end
end
end)
The original problem was the fact you were getting the SCRIPTS only once! meaning if someone were to reset the children would come back as ‘nil’ or parentless meaning they were useless or non-functional.
yes, I solved the issue partially already. The code works, and as I mentioned in an older reply, the only script that doesn’t work upon playing (for some reason) is the camera bobbing effect that only works after a death or reset
Glad I was able to help! A camera bobbing script may have to be reset or re-activated every time someone resets or respawns, I’m not sure how yours work so it is hard to help you. If you would like to give more context I will try to help you as much as I can!