Depreciated Variables (Faster Solution by any chance?)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Get all of depreciated variables to change all at once…instead of manually opening each and control + v
  2. What is the issue? Include screenshots / videos if possible!
    image
    I want to change all of the “Game” to “game” for the scripts
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Nothing at the moment.

You can modify the script’s ‘Source’ property and use string.gsub() to replace Game with game.

local services = {}
for i,v in pairs(game:GetChildren()) do
    pcall(function()
        services[#services + 1] = game:GetService(v.Name)
    end)
end

for i,service in pairs(services) do
    pcall(function()
        if v:IsA('Script') or v:IsA('LocalScript') or v:IsA('ModuleScript') then
            local newScript = string.gsub(v.Source, 'Game', 'game')
            v.Source = newScript
        end
    end)
end

I’m talking about changing all the scripts that are using the variable, “Game” to “game” instead of manually opening each script and changing the variable to game by using the command bar.

You can input that script to the command bar and it would do that.

It did not work, and it didn’t show any errors when I execute via command bar.

Check your scripts that had Game, it should be replaced with game.

Nope, it didn’t replace the depreciated variables.

I made an edit to the script post, try that.

Edit, I tried it and it didn’t work, give me a few and I’ll fix.

There we go:

local services = {}
for i,v in pairs(game:GetChildren()) do
    pcall(function()
        services[#services + 1] = game:GetService(v.Name)
    end)
end

for i,service in pairs(services) do 
    for i,v in pairs(service:GetDescendants()) do
        pcall(function()
            if v:IsA('LuaSourceContainer') then
                local newScript = string.gsub(v.Source, 'Game', 'game')
                v.Source = newScript
            end
        end)
    end 
end

The manual way to do it is open each affected script and press CTRL+H, which brings up the “find and replace” tool. Enter “Game” as your “find” and “game” as your replace, and press replace all.

There may be an option to do this across all scripts, as some code editors do, but I’m not 100% sure on that.

A find + replace all system for all scripts at once was just highlighted in the roadmap!

1 Like

That’s cool and good news to hear :slight_smile:

local services = {}
for i,v in pairs(game:GetChildren()) do
    pcall(function()
        services[#services + 1] = game:GetService(v.Name)
    end)
end

for i,service in pairs(services) do 
    for i,v in pairs(service:GetDescendants()) do
        pcall(function()
            if v:IsA('LuaSourceContainer') then
                local newScript = string.gsub(v.Source, 'while true do 
 script.Parent.Y.Color=Color3.new() 
script.Parent.R.Color=Color3.new(1,0,0) 
wait(22.05) 
script.Parent.Y.Color=Color3.new() 
script.Parent.R.Color=Color3.new() 
script.Parent.G.Color=Color3.new(0,1,0) 
wait(17.5)
script.Parent.G.Color=Color3.new() 
script.Parent.Y.Color=Color3.new(1,1,0) 
wait(2.55)  
 end 
', 'while true do 
	script.Parent.R.SurfaceLight.Enabled = false
script.Parent.Y.Color=Color3.new() 
	script.Parent.R.Color=Color3.new() 
	script.Parent.G.SurfaceLight.Enabled = true
script.Parent.G.Color=Color3.new(0,1,0) 
	wait(17.5)
	script.Parent.G.SurfaceLight.Enabled = false
	script.Parent.G.Color=Color3.new() 
	script.Parent.Y.SurfaceLight.Enabled = true
script.Parent.Y.Color=Color3.new(1,1,0) 
	wait(2.55)  
	script.Parent.Y.SurfaceLight.Enabled = false
 script.Parent.Y.Color=Color3.new() 
	script.Parent.R.Color=Color3.new(1,0,0)
	script.Parent.R.SurfaceLight.Enabled = true
wait(22.05) 
 end 
')
                v.Source = newScript
            end
        end)
    end 
end

How come this doesn’t work?