Hello devs 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