How to enable StarterCharacterScripts via a localscript?

How can I enable disabled scripts inside of StarterCharacterScripts? I have these 2 localscripts inside of StarterCharacterScripts and they are currently disabled but I want to be able to enable them via a localscript not located in StarterCharacterScripts. Is it possible to do it?

3 Likes
-- Get services
local players = game:GetService("Players")
local starterPlayer = game:GetService("StarterPlayer")
local starterCharacterScripts = starterPlayer:WaitForChild("StarterCharacterScripts")

-- Get player and character
local player = players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

-- Set existing local scripts
char:WaitForChild("LocalScript1").Enabled = true
char:WaitForChild("LocalScript2").Enabled = true

-- Set local scripts when a new character is added just incase the character dies (optional)
local function characterAdded(newChar)
	newChar:WaitForChild("LocalScript1").Enabled = true
	newChar:WaitForChild("LocalScript2").Enabled = true
end

player.CharacterAdded:Connect(characterAdded)

Edit 1: Realized character is created on the server, edited accordingly

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.