#Module Script x Server Script Sending Information
6 messages · Page 1 of 1 (latest)
17:47:58.444 Event is not a valid member of RemoteEvent "ReplicatedStorage.Events.GameOver" - Server - Spawning:19
local playbackSpeedFactor = 2.5 -- Factor to adjust animation playback speed (1 = normal speed)
local Points = workspace.Points -- Reference to the Points folder in workspace
local events = game.ReplicatedStorage.Events
local GameOver = events.GameOver
local wave = 1
local spawner = workspace.Map.Start
local Enemies = 0
local tower = require(script.ModuleScript) -- Ensure to require your tower module
local base = require(script.Base) -- Ensure to require your base module
-- A flag to indicate if the game is over
local gameOver = false
function UpdateHp(HP)
base.updateHealth(HP)
end
GameOver.Event:Connect(function()
gameOver = true
end)
local GameOver = game.ReplicatedStorage.Events.GameOver
local base = {}
function base.Setup(health)
base.Model = workspace:WaitForChild("Exit")
base.CurrentHealth = health
base.MaxHealth = health
base.updateHealth() -- Call the function to update health on setup
end
function base.updateHealth(damage)
if damage then
base.CurrentHealth = base.CurrentHealth - damage -- Use = instead of -=
end
-- Calculate health percentage
local healthPercentage = math.clamp(base.CurrentHealth / base.MaxHealth, 0, 1) -- Ensure it's between 0 and 1
-- Get GUI reference
local gui = base.Model.HealthGui
-- Update the size based on health percentage
gui.CurrentHealth.Size = UDim2.new(healthPercentage, 0, 0.5, 0) -- Full height, width based on health percentage
if base.CurrentHealth <= 0 then
GameOver:Fire() -- Fire GameOver event
base.CurrentHealth = 0 -- Prevent negative health
else
gui.TextLabel.Text = "Base " .. base.CurrentHealth .. "/" .. base.MaxHealth
end
end
return base -- Ensure to return the base table
Oh nvm
fixed it