Problem with injured GUI (Syntax error: Expected 'end (to close 'then' at line 31, got <eof>; did you forget to close the then at line45?)

Hello devs :wave:t5: I just recently started to learn how to script and I’m working on a Roleplay game How do I fix this so it won’t happen again? and can you please explain the problem to me?

Output: Syntax error: Expected 'end (to close 'then' at line 31, got <eof>; did you forget to close the then at line45?)

Script


--Variables
local setting = require(script.Settings)

local char = script.Parent
local hum = char.Humanoid

local gui = script.InjuredGui
local EDead = script.EDead
local currentGui

--Run time code
if char:FindFirstChild("Health") then char.Health:Destroy() end

--Functions
hum.HealthChanged:Connect(function(health)
	if health <= setting.Injured_Health then
		local clone = gui:Clone()
		clone.Enabled = true
		clone.Parent = char.Head
		currentGui = clone
		
		hum.PlatformStand = false
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		
	elseif health >= setting.Good_Health then
		if currentGui then currentGui:Destroy() end
		
		hum.PlatformStand = false
		hum.WalkSpeed = 5
		hum.JumpPower = 50
		
		hum.HealthChanged:Connect(function(health)
			if health <= setting.Dead_Health then
				local clone = EDead:Clone()
				clone.Enabled = true
				clone.Parent = char.Head
				currentGui = clone 
				
			elseif health >= setting.Good_Health then
			if currentGui then currentGui:Destroy()end
		
	end
end)

Settings Module:

local module = 
{
	Injured_Health = 25; 
	Good_Health = 50;	 
	Dead_Health = 0;
}

return module

Screeshots

image
image

Your script was expecting an end for each function, and i calculated here that you have two functions without end

do you know where I should put the end funtions?

add after this: if currentGui then currentGui:Destroy()end in next line: end and in next line end)

Try this:


--Variables
local setting = require(script.Settings)

local char = script.Parent
local hum = char.Humanoid

local gui = script.InjuredGui
local EDead = script.EDead
local currentGui

--Run time code
if char:FindFirstChild("Health") then char.Health:Destroy() end

--Functions
hum.HealthChanged:Connect(function(health)
	if health <= setting.Injured_Health then
		local clone = gui:Clone()
		clone.Enabled = true
		clone.Parent = char.Head
		currentGui = clone

		hum.PlatformStand = false
		hum.WalkSpeed = 0
		hum.JumpPower = 0

	elseif health >= setting.Good_Health then
		if currentGui then currentGui:Destroy() end

		hum.PlatformStand = false
		hum.WalkSpeed = 5
		hum.JumpPower = 50

		hum.HealthChanged:Connect(function(health)
			if health <= setting.Dead_Health then
				local clone = EDead:Clone()
				clone.Enabled = true
				clone.Parent = char.Head
				currentGui = clone 

			elseif health >= setting.Good_Health then
				if currentGui then currentGui:Destroy()end
			end
		end)
	end
end)
1 Like

no luck the EDead billboard GUI Doesn’t appear even though the player is dead

billboard GUI doesn’t appear
image