I'm a small game creator i have a problem with Base Health in my TD game how to fix it? problem is: ServerScriptService.Main.Base:20: attempt to perform arithmetic (div) on nil Help pls
local serverstorage = game:GetService("ServerStorage")
local Bindables = serverstorage:WaitForChild("Bindables")
local UpdateHealthEvent = Bindables:WaitForChild("UpdateBaseHealth")
local GameOverEvent = Bindables:WaitForChild("GameOver")
local Base = {}
function Base.Setup(map, health)
Base.Model = workspace.map.Base
Base.CurrentHealth = health
Base.MaxHealth = health
Base.UpdateHealth()
end
function Base.UpdateHealth(damage)
if damage then
Base.CurrentHealth -= damage
end
local gui = workspace.map.Base.HealthGui
local precent = Base.CurrentHealth / Base.MaxHealth
gui.CurrentHealth.Size = UDim2.new(precent, 0, 0.5, 0)
if Base.CurrentHealth <= 0 then
GameOverEvent:Fire()
print("gameover")
gui.Title.Text = "Base:Destroyed "
end
gui.Title.Text = "Base: " .. Base.CurrentHealth .. "/" .. Base.MaxHealth
end
UpdateHealthEvent.Event:Connect(Base.UpdateHealth())
return Base
~~~~~~~~~~~~~~~~~i

1 comment
please edit your post and make the ~~~ on a differrent line so its all in a texbox, and we can see what line the error is on. Also, can I help you with your tds game?