How to patch/fix Roblox CoreScripts (i.e HealthScript, PlayerList)

Introduction

Hello,

This is a tutorial on patching/fixing Roblox CoreScripts. This is a very basic and bare bones explanation. I’ve made a script that automatically parents them to their respective locations depending on the year selected in ReplicatedStorage. I like to call it patching, but you can call it whatever you want.

Steps

First, you have to have a CoreScript ready. For this, we’re going to be using the 2014/2015 HealthScript. Here’s the code:

--[[ 
	This script controls the gui the player sees in regards to his or her health.
	Can be turned with Game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)
	Copyright ROBLOX 2014. Written by Ben Tkacheff.
--]]

---------------------------------------------------------------------
-- Initialize/Variables
while not Game do
	wait(1/60)
end
while not Game:GetService("Players") do
	wait(1/60)
end

local useCoreHealthBar = false
local success = pcall(function() useCoreHealthBar = Game:GetService("Players"):GetUseCoreScriptHealthBar() end)
if not success or not useCoreHealthBar then
	return
end

local currentHumanoid = nil

local HealthGui = nil
local lastHealth = 100
local HealthPercentageForOverlay = 5
local maxBarTweenTime = 0.3
local greenColor = Color3.new(0.2, 1, 0.2)
local redColor = Color3.new(1, 0.2, 0.2)
local yellowColor = Color3.new(1, 1, 0.2)

local guiEnabled = false
local healthChangedConnection = nil
local humanoidDiedConnection = nil
local characterAddedConnection = nil

local greenBarImage = "rbxasset://textures/ui/Health-BKG-Center.png"
local greenBarImageLeft = "rbxasset://textures/ui/Health-BKG-Left-Cap.png"
local greenBarImageRight = "rbxasset://textures/ui/Health-BKG-Right-Cap.png"
local hurtOverlayImage = "http://www.roblox.com/asset/?id=34854607"

Game:GetService("ContentProvider"):Preload(greenBarImage)
Game:GetService("ContentProvider"):Preload(hurtOverlayImage)

while not Game:GetService("Players").LocalPlayer do
	wait(1/60)
end

---------------------------------------------------------------------
-- Functions

local capHeight = 15
local capWidth = 7

function CreateGui()
	if HealthGui and #HealthGui:GetChildren() > 0 then 
		HealthGui.Parent = Game:GetService("CoreGui").RobloxGui
		return 
	end

	local hurtOverlay = Instance.new("ImageLabel")
	hurtOverlay.Name = "HurtOverlay"
	hurtOverlay.BackgroundTransparency = 1
	hurtOverlay.Image = hurtOverlayImage
	hurtOverlay.Position = UDim2.new(-10,0,-10,0)
	hurtOverlay.Size = UDim2.new(20,0,20,0)
	hurtOverlay.Visible = false
	hurtOverlay.Parent = HealthGui
	
	local healthFrame = Instance.new("Frame")
	healthFrame.Name = "HealthFrame"
	healthFrame.BackgroundTransparency = 1
	healthFrame.BackgroundColor3 = Color3.new(1,1,1)
	healthFrame.BorderColor3 = Color3.new(0,0,0)
	healthFrame.BorderSizePixel = 0
	healthFrame.Position = UDim2.new(0.5,-85,1,-20)
	healthFrame.Size = UDim2.new(0,170,0,capHeight)
	healthFrame.Parent = HealthGui


	local healthBarBackCenter = Instance.new("ImageLabel")
	healthBarBackCenter.Name = "healthBarBackCenter"
	healthBarBackCenter.BackgroundTransparency = 1
	healthBarBackCenter.Image = greenBarImage
	healthBarBackCenter.Size = UDim2.new(1,-capWidth*2,1,0)
	healthBarBackCenter.Position = UDim2.new(0,capWidth,0,0)
	healthBarBackCenter.Parent = healthFrame
	healthBarBackCenter.ImageColor3 = Color3.new(1,1,1)

	local healthBarBackLeft = Instance.new("ImageLabel")
	healthBarBackLeft.Name = "healthBarBackLeft"
	healthBarBackLeft.BackgroundTransparency = 1
	healthBarBackLeft.Image = greenBarImageLeft
	healthBarBackLeft.Size = UDim2.new(0,capWidth,1,0)
	healthBarBackLeft.Position = UDim2.new(0,0,0,0)
	healthBarBackLeft.Parent = healthFrame
	healthBarBackLeft.ImageColor3 = Color3.new(1,1,1)

	local healthBarBackRight = Instance.new("ImageLabel")
	healthBarBackRight.Name = "healthBarBackRight"
	healthBarBackRight.BackgroundTransparency = 1
	healthBarBackRight.Image = greenBarImageRight
	healthBarBackRight.Size = UDim2.new(0,capWidth,1,0)
	healthBarBackRight.Position = UDim2.new(1,-capWidth,0,0)
	healthBarBackRight.Parent = healthFrame
	healthBarBackRight.ImageColor3 = Color3.new(1,1,1)


	local healthBar = Instance.new("Frame")
	healthBar.Name = "HealthBar"
	healthBar.BackgroundTransparency = 1
	healthBar.BackgroundColor3 = Color3.new(1,1,1)
	healthBar.BorderColor3 = Color3.new(0,0,0)
	healthBar.BorderSizePixel = 0
	healthBar.ClipsDescendants = true
	healthBar.Position = UDim2.new(0, 0, 0, 0)
	healthBar.Size = UDim2.new(1,0,1,0)
	healthBar.Parent = healthFrame


	local healthBarCenter = Instance.new("ImageLabel")
	healthBarCenter.Name = "healthBarCenter"
	healthBarCenter.BackgroundTransparency = 1
	healthBarCenter.Image = greenBarImage
	healthBarCenter.Size = UDim2.new(1,-capWidth*2,1,0)
	healthBarCenter.Position = UDim2.new(0,capWidth,0,0)
	healthBarCenter.Parent = healthBar
	healthBarCenter.ImageColor3 = greenColor

	local healthBarLeft = Instance.new("ImageLabel")
	healthBarLeft.Name = "healthBarLeft"
	healthBarLeft.BackgroundTransparency = 1
	healthBarLeft.Image = greenBarImageLeft
	healthBarLeft.Size = UDim2.new(0,capWidth,1,0)
	healthBarLeft.Position = UDim2.new(0,0,0,0)
	healthBarLeft.Parent = healthBar
	healthBarLeft.ImageColor3 = greenColor

	local healthBarRight = Instance.new("ImageLabel")
	healthBarRight.Name = "healthBarRight"
	healthBarRight.BackgroundTransparency = 1
	healthBarRight.Image = greenBarImageRight
	healthBarRight.Size = UDim2.new(0,capWidth,1,0)
	healthBarRight.Position = UDim2.new(1,-capWidth,0,0)
	healthBarRight.Parent = healthBar
	healthBarRight.ImageColor3 = greenColor

	HealthGui.Parent = Game:GetService("CoreGui").RobloxGui
end

function UpdateGui(health)
	if not HealthGui then return end
	
	local healthFrame = HealthGui:FindFirstChild("HealthFrame")
	if not healthFrame then return end
	
	local healthBar = healthFrame:FindFirstChild("HealthBar")
	if not healthBar then return end
	
	-- If more than 1/4 health, bar = green.  Else, bar = red.
	local percentHealth = (health/currentHumanoid.MaxHealth)
	if percentHealth ~= percentHealth then
		percentHealth = 1
		healthBar.healthBarCenter.ImageColor3 = yellowColor
		healthBar.healthBarRight.ImageColor3 = yellowColor
		healthBar.healthBarLeft.ImageColor3 = yellowColor
	elseif percentHealth > 0.25  then		
		healthBar.healthBarCenter.ImageColor3 = greenColor
		healthBar.healthBarRight.ImageColor3 = greenColor
		healthBar.healthBarLeft.ImageColor3 = greenColor
	else
		healthBar.healthBarCenter.ImageColor3 = redColor
		healthBar.healthBarRight.ImageColor3 = redColor
		healthBar.healthBarLeft.ImageColor3 = redColor
	end
		
	local width = (health / currentHumanoid.MaxHealth)
 	width = math.max(math.min(width,1),0) -- make sure width is between 0 and 1
 	if width ~= width then width = 1 end

	local healthDelta = lastHealth - health
	lastHealth = health
	
	local percentOfTotalHealth = math.abs(healthDelta/currentHumanoid.MaxHealth)
	percentOfTotalHealth = math.max(math.min(percentOfTotalHealth,1),0) -- make sure percentOfTotalHealth is between 0 and 1
	if percentOfTotalHealth ~= percentOfTotalHealth then percentOfTotalHealth = 1 end

	local newHealthSize = UDim2.new(width,0,1,0)
	
	healthBar.Size = newHealthSize

	local sizeX = healthBar.AbsoluteSize.X
	if sizeX < capWidth then
		healthBar.healthBarCenter.Visible = false
		healthBar.healthBarRight.Visible = false
	elseif sizeX < (2*capWidth + 1) then
		healthBar.healthBarCenter.Visible = true
		healthBar.healthBarCenter.Size = UDim2.new(0,sizeX - capWidth,1,0)
		healthBar.healthBarRight.Visible = false
	else
		healthBar.healthBarCenter.Visible = true
		healthBar.healthBarCenter.Size = UDim2.new(1,-capWidth*2,1,0)
		healthBar.healthBarRight.Visible = true
	end

	local thresholdForHurtOverlay = currentHumanoid.MaxHealth * (HealthPercentageForOverlay/100)
	
	if healthDelta >= thresholdForHurtOverlay then
		AnimateHurtOverlay()
	end

end

function AnimateHurtOverlay()
	if not HealthGui then return end
	
	local overlay = HealthGui:FindFirstChild("HurtOverlay")
	if not overlay then return end
	
	local newSize = UDim2.new(20, 0, 20, 0)
	local newPos = UDim2.new(-10, 0, -10, 0)

	if overlay:IsDescendantOf(Game) then
		-- stop any tweens on overlay
		overlay:TweenSizeAndPosition(newSize,newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Linear,0,true,function()
			
			-- show the gui
			overlay.Size = UDim2.new(1,0,1,0)
			overlay.Position = UDim2.new(0,0,0,0)
			overlay.Visible = true
			
			-- now tween the hide
			if overlay:IsDescendantOf(Game) then
				overlay:TweenSizeAndPosition(newSize,newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,10,false,function()
					overlay.Visible = false
				end)
			else
				overlay.Size = newSize
				overlay.Position = newPos
			end
		end)
	else
		overlay.Size = newSize
		overlay.Position = newPos
	end

end

function humanoidDied()
	 UpdateGui(0)
end

function disconnectPlayerConnections()
	if characterAddedConnection then characterAddedConnection:disconnect() end
	if humanoidDiedConnection then humanoidDiedConnection:disconnect() end
	if healthChangedConnection then healthChangedConnection:disconnect() end
end

function newPlayerCharacter()
	disconnectPlayerConnections()
	startGui()
end

function startGui()
	characterAddedConnection = Game:GetService("Players").LocalPlayer.CharacterAdded:connect(newPlayerCharacter)

	local character = Game:GetService("Players").LocalPlayer.Character
	if not character then
		return
	end

	currentHumanoid = character:WaitForChild("Humanoid")
	if not currentHumanoid then
		return
	end

	if not Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
		return
	end

	healthChangedConnection = currentHumanoid.HealthChanged:connect(UpdateGui)
	humanoidDiedConnection = currentHumanoid.Died:connect(humanoidDied)
	UpdateGui(currentHumanoid.Health)
		
	CreateGui()
end



---------------------------------------------------------------------
-- Start Script

HealthGui = Instance.new("Frame")
HealthGui.Name = "HealthGui"
HealthGui.BackgroundTransparency = 1
HealthGui.Size = UDim2.new(1,0,1,0)

Game:GetService("StarterGui").CoreGuiChangedSignal:connect(function(coreGuiType,enabled)
	if coreGuiType == Enum.CoreGuiType.Health or coreGuiType == Enum.CoreGuiType.All then
		if guiEnabled and not enabled then
			if HealthGui then
				HealthGui.Parent = nil
			end
			disconnectPlayerConnections()
		elseif not guiEnabled and enabled then
			startGui()
		end
		
		guiEnabled = enabled
	end
end)

if Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
	guiEnabled = true
	startGui()
end

Second, you need to open Roblox Studio and create a blank Baseplate. Make a ScreenGui and name it whatever you want, set ResetOnSpawn to false, set IgnoreGuiInset to what you prefer, and set DisplayOrder to what you prefer (I prefer 2).

Third, you need to create a LocalScript and name it whatever you want inside the ScreenGui. Now, paste the code from the link earlier into the LocalScript.

Alright, so now, what do we do? If you test it out in play mode, it’ll error due to RobloxScriptSecurity. Here’s what you should probably be doing here:

--[[
	replace CoreGui/RobloxGui parents to script.Parent
	remove any FFlags (for example at useCoreHealthBar, set it to true and remove the code below it that sets it depending on if it's enabled)
	remove any checks to see if the specified CoreGui is enabled (for example, GetCoreGuiEnabled and CoreGuiChangedSignal)
--]]

Here’s what you should do:

Around the end of the script, there is a check to make sure that the Enum.CoreGuiType.Health is enabled. However, if we do this check and you have CoreGuiType.Health disabled, it will not work. Replace this:

if Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
	guiEnabled = true
	startGui()
end

with this:

guiEnabled = true
startGui()

Also, remove the code that connects to CoreGuiChangedSignal:

Game:GetService("StarterGui").CoreGuiChangedSignal:connect(function(coreGuiType,enabled)
	if coreGuiType == Enum.CoreGuiType.Health or coreGuiType == Enum.CoreGuiType.All then
		if guiEnabled and not enabled then
			if HealthGui then
				HealthGui.Parent = nil
			end
			disconnectPlayerConnections()
		elseif not guiEnabled and enabled then
			startGui()
		end
		
		guiEnabled = enabled
	end
end)

Remove this code block in startGui():

if not Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
	return
end

You should be done now, test it out in play mode. If it works, congratulations! You just patched/fixed a 2014/2015 HealthScript!

Final results:

--[[ 
	This script controls the gui the player sees in regards to his or her health.
	Can be turned with Game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)
	Copyright ROBLOX 2014. Written by Ben Tkacheff.
--]]

---------------------------------------------------------------------
-- Initialize/Variables
while not Game do
	wait(1/60)
end
while not Game:GetService("Players") do
	wait(1/60)
end

local useCoreHealthBar = true

local currentHumanoid = nil

local HealthGui = nil
local lastHealth = 100
local HealthPercentageForOverlay = 5
local maxBarTweenTime = 0.3
local greenColor = Color3.new(0.2, 1, 0.2)
local redColor = Color3.new(1, 0.2, 0.2)
local yellowColor = Color3.new(1, 1, 0.2)

local guiEnabled = false
local healthChangedConnection = nil
local humanoidDiedConnection = nil
local characterAddedConnection = nil

local greenBarImage = "rbxasset://textures/ui/Health-BKG-Center.png"
local greenBarImageLeft = "rbxasset://textures/ui/Health-BKG-Left-Cap.png"
local greenBarImageRight = "rbxasset://textures/ui/Health-BKG-Right-Cap.png"
local hurtOverlayImage = "http://www.roblox.com/asset/?id=34854607"

Game:GetService("ContentProvider"):Preload(greenBarImage)
Game:GetService("ContentProvider"):Preload(hurtOverlayImage)

while not Game:GetService("Players").LocalPlayer do
	wait(1/60)
end

---------------------------------------------------------------------
-- Functions

local capHeight = 15
local capWidth = 7

function CreateGui()
	if HealthGui and #HealthGui:GetChildren() > 0 then 
		HealthGui.Parent = script.Parent
		return 
	end

	local hurtOverlay = Instance.new("ImageLabel")
	hurtOverlay.Name = "HurtOverlay"
	hurtOverlay.BackgroundTransparency = 1
	hurtOverlay.Image = hurtOverlayImage
	hurtOverlay.Position = UDim2.new(-10,0,-10,0)
	hurtOverlay.Size = UDim2.new(20,0,20,0)
	hurtOverlay.Visible = false
	hurtOverlay.Parent = HealthGui

	local healthFrame = Instance.new("Frame")
	healthFrame.Name = "HealthFrame"
	healthFrame.BackgroundTransparency = 1
	healthFrame.BackgroundColor3 = Color3.new(1,1,1)
	healthFrame.BorderColor3 = Color3.new(0,0,0)
	healthFrame.BorderSizePixel = 0
	healthFrame.Position = UDim2.new(0.5,-85,1,-20)
	healthFrame.Size = UDim2.new(0,170,0,capHeight)
	healthFrame.Parent = HealthGui


	local healthBarBackCenter = Instance.new("ImageLabel")
	healthBarBackCenter.Name = "healthBarBackCenter"
	healthBarBackCenter.BackgroundTransparency = 1
	healthBarBackCenter.Image = greenBarImage
	healthBarBackCenter.Size = UDim2.new(1,-capWidth*2,1,0)
	healthBarBackCenter.Position = UDim2.new(0,capWidth,0,0)
	healthBarBackCenter.Parent = healthFrame
	healthBarBackCenter.ImageColor3 = Color3.new(1,1,1)

	local healthBarBackLeft = Instance.new("ImageLabel")
	healthBarBackLeft.Name = "healthBarBackLeft"
	healthBarBackLeft.BackgroundTransparency = 1
	healthBarBackLeft.Image = greenBarImageLeft
	healthBarBackLeft.Size = UDim2.new(0,capWidth,1,0)
	healthBarBackLeft.Position = UDim2.new(0,0,0,0)
	healthBarBackLeft.Parent = healthFrame
	healthBarBackLeft.ImageColor3 = Color3.new(1,1,1)

	local healthBarBackRight = Instance.new("ImageLabel")
	healthBarBackRight.Name = "healthBarBackRight"
	healthBarBackRight.BackgroundTransparency = 1
	healthBarBackRight.Image = greenBarImageRight
	healthBarBackRight.Size = UDim2.new(0,capWidth,1,0)
	healthBarBackRight.Position = UDim2.new(1,-capWidth,0,0)
	healthBarBackRight.Parent = healthFrame
	healthBarBackRight.ImageColor3 = Color3.new(1,1,1)


	local healthBar = Instance.new("Frame")
	healthBar.Name = "HealthBar"
	healthBar.BackgroundTransparency = 1
	healthBar.BackgroundColor3 = Color3.new(1,1,1)
	healthBar.BorderColor3 = Color3.new(0,0,0)
	healthBar.BorderSizePixel = 0
	healthBar.ClipsDescendants = true
	healthBar.Position = UDim2.new(0, 0, 0, 0)
	healthBar.Size = UDim2.new(1,0,1,0)
	healthBar.Parent = healthFrame


	local healthBarCenter = Instance.new("ImageLabel")
	healthBarCenter.Name = "healthBarCenter"
	healthBarCenter.BackgroundTransparency = 1
	healthBarCenter.Image = greenBarImage
	healthBarCenter.Size = UDim2.new(1,-capWidth*2,1,0)
	healthBarCenter.Position = UDim2.new(0,capWidth,0,0)
	healthBarCenter.Parent = healthBar
	healthBarCenter.ImageColor3 = greenColor

	local healthBarLeft = Instance.new("ImageLabel")
	healthBarLeft.Name = "healthBarLeft"
	healthBarLeft.BackgroundTransparency = 1
	healthBarLeft.Image = greenBarImageLeft
	healthBarLeft.Size = UDim2.new(0,capWidth,1,0)
	healthBarLeft.Position = UDim2.new(0,0,0,0)
	healthBarLeft.Parent = healthBar
	healthBarLeft.ImageColor3 = greenColor

	local healthBarRight = Instance.new("ImageLabel")
	healthBarRight.Name = "healthBarRight"
	healthBarRight.BackgroundTransparency = 1
	healthBarRight.Image = greenBarImageRight
	healthBarRight.Size = UDim2.new(0,capWidth,1,0)
	healthBarRight.Position = UDim2.new(1,-capWidth,0,0)
	healthBarRight.Parent = healthBar
	healthBarRight.ImageColor3 = greenColor

	HealthGui.Parent = script.Parent
end

function UpdateGui(health)
	if not HealthGui then return end

	local healthFrame = HealthGui:FindFirstChild("HealthFrame")
	if not healthFrame then return end

	local healthBar = healthFrame:FindFirstChild("HealthBar")
	if not healthBar then return end

	-- If more than 1/4 health, bar = green.  Else, bar = red.
	local percentHealth = (health/currentHumanoid.MaxHealth)
	if percentHealth ~= percentHealth then
		percentHealth = 1
		healthBar.healthBarCenter.ImageColor3 = yellowColor
		healthBar.healthBarRight.ImageColor3 = yellowColor
		healthBar.healthBarLeft.ImageColor3 = yellowColor
	elseif percentHealth > 0.25  then		
		healthBar.healthBarCenter.ImageColor3 = greenColor
		healthBar.healthBarRight.ImageColor3 = greenColor
		healthBar.healthBarLeft.ImageColor3 = greenColor
	else
		healthBar.healthBarCenter.ImageColor3 = redColor
		healthBar.healthBarRight.ImageColor3 = redColor
		healthBar.healthBarLeft.ImageColor3 = redColor
	end

	local width = (health / currentHumanoid.MaxHealth)
	width = math.max(math.min(width,1),0) -- make sure width is between 0 and 1
	if width ~= width then width = 1 end

	local healthDelta = lastHealth - health
	lastHealth = health

	local percentOfTotalHealth = math.abs(healthDelta/currentHumanoid.MaxHealth)
	percentOfTotalHealth = math.max(math.min(percentOfTotalHealth,1),0) -- make sure percentOfTotalHealth is between 0 and 1
	if percentOfTotalHealth ~= percentOfTotalHealth then percentOfTotalHealth = 1 end

	local newHealthSize = UDim2.new(width,0,1,0)

	healthBar.Size = newHealthSize

	local sizeX = healthBar.AbsoluteSize.X
	if sizeX < capWidth then
		healthBar.healthBarCenter.Visible = false
		healthBar.healthBarRight.Visible = false
	elseif sizeX < (2*capWidth + 1) then
		healthBar.healthBarCenter.Visible = true
		healthBar.healthBarCenter.Size = UDim2.new(0,sizeX - capWidth,1,0)
		healthBar.healthBarRight.Visible = false
	else
		healthBar.healthBarCenter.Visible = true
		healthBar.healthBarCenter.Size = UDim2.new(1,-capWidth*2,1,0)
		healthBar.healthBarRight.Visible = true
	end

	local thresholdForHurtOverlay = currentHumanoid.MaxHealth * (HealthPercentageForOverlay/100)

	if healthDelta >= thresholdForHurtOverlay then
		AnimateHurtOverlay()
	end

end

function AnimateHurtOverlay()
	if not HealthGui then return end

	local overlay = HealthGui:FindFirstChild("HurtOverlay")
	if not overlay then return end

	local newSize = UDim2.new(20, 0, 20, 0)
	local newPos = UDim2.new(-10, 0, -10, 0)

	if overlay:IsDescendantOf(Game) then
		-- stop any tweens on overlay
		overlay:TweenSizeAndPosition(newSize,newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Linear,0,true,function()

			-- show the gui
			overlay.Size = UDim2.new(1,0,1,0)
			overlay.Position = UDim2.new(0,0,0,0)
			overlay.Visible = true

			-- now tween the hide
			if overlay:IsDescendantOf(Game) then
				overlay:TweenSizeAndPosition(newSize,newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,10,false,function()
					overlay.Visible = false
				end)
			else
				overlay.Size = newSize
				overlay.Position = newPos
			end
		end)
	else
		overlay.Size = newSize
		overlay.Position = newPos
	end

end

function humanoidDied()
	UpdateGui(0)
end

function disconnectPlayerConnections()
	if characterAddedConnection then characterAddedConnection:disconnect() end
	if humanoidDiedConnection then humanoidDiedConnection:disconnect() end
	if healthChangedConnection then healthChangedConnection:disconnect() end
end

function newPlayerCharacter()
	disconnectPlayerConnections()
	startGui()
end

function startGui()
	characterAddedConnection = Game:GetService("Players").LocalPlayer.CharacterAdded:connect(newPlayerCharacter)

	local character = Game:GetService("Players").LocalPlayer.Character
	if not character then
		return
	end

	currentHumanoid = character:WaitForChild("Humanoid")
	if not currentHumanoid then
		return
	end

	healthChangedConnection = currentHumanoid.HealthChanged:connect(UpdateGui)
	humanoidDiedConnection = currentHumanoid.Died:connect(humanoidDied)
	UpdateGui(currentHumanoid.Health)

	CreateGui()
end



---------------------------------------------------------------------
-- Start Script

HealthGui = Instance.new("Frame")
HealthGui.Name = "HealthGui"
HealthGui.BackgroundTransparency = 1
HealthGui.Size = UDim2.new(1,0,1,0)

guiEnabled = true
startGui()

If you want to find more CoreScripts, you can go back in the commits of Roblox’s CoreScript repository. You can find that on Roblox’s GitHub (Roblox/Core-Scripts). It goes back to April 22, 2014. If you want to find even older Roblox CoreScripts, there’s some archives online that you can look through.

Remember that this is just a basic tutorial, and doesn’t go in-depth with patching/fixing some more recent CoreScripts, such as mid-2015+ CoreScripts. Those are a tiny bit more difficult, not by much however. It also doesn’t discuss anything about CenterDialogs, SetVerb, and a few other things. Just keep practicing if you can’t do those yet, eventually you will be able to do those ones. If you feel like it, you can attempt patch the most recent CoreScripts that Roblox released on their repository that I mentioned earlier. They’re from 2018.

Thanks for reading! If there’s any mistakes, PM me or reply.
p0s_0.

5 Likes

If there’s no point to this, why is it here? Tutorials are intended to teach you how to do something because it has actual utility for developers. What are we supposed to get out of this? How can we apply it to other code and not just old CoreScripts? How is it useful to us now?

Also, worth noting:

This is wrong information. rbxassetid is a ContentId shorthand for the longer link: /asset is not deprecated and if that endpoint fails to work then similarly rbxassetid would fail to work. Content on the Developer Hub for more information.

2 Likes

ive seen some grammar issues in your text replace all the “want” with “have” lol also I liked your text but as @colbert2677 said there’s some wrong information I prefer you to re-write your text and upload it

1 Like