Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local serverstorage = game:GetService("ServerStorage")
- local bindables = serverstorage:WaitForChild("Bindables")
- local updateasehealthEvent = bindables:WaitForChild("UpdateBaseHealth")
- local gameoverEvent = bindables:WaitForChild("GameOver")
- local base = {}
- function base.Setup(map, health)
- base.Model = map:WaitForChild("Base")
- base.CurrentHealth = health
- base.MaxHealth = health
- base.UpdateHealth()
- end
- function base.UpdateHealth(damage)
- if damage then
- base.CurrentHealth -= damage
- end
- local gui = base.Model.HealthGui
- local percent = base.CurrentHealth / base.MaxHealth
- gui.CurrentHealth.Size = UDim2.new(percent,0,0.5,0)
- if base.CurrentHealth <= 0 then
- gameoverEvent:Fire()
- gui.Title.Text = "Base: DESTROYED"
- else
- gui.Title.Text = "Base: ".. base.CurrentHealth .."/".. base.MaxHealth
- end
- end
- updateasehealthEvent.Event:Connect(base.UpdateHealth)
- return base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement