When the caller leaves the module stops the code entirely. For example, if I were to do this in a module
-- The script that calls the module local Player = game.Players.LocalPlayer local EnemyPlayer = workspace.EnemyPlayer local Module = require(game.ReplicatedStorage.Module) module.Call(EnemyPlayer)
--Module Call EnemyPlayer.Humanoid:TakeDamage(20) wait(20) EnemyPlayer.Humanoid:TakeDamage(20)
If the Player were the one to call the module and leave between the wait time, the second damage wouldn't happen. How do I fix this?
Well you can't damage a Player when they leave, but you can avoid the error by checking if the EnemyPlayer exists before damaging them.
if game.Players:FindFirstChild(EnemyPlayer.Name) then EnemyPlayer.Humanoid:TakeDamage(20) end