Hello. I wrote a module for player diseases. For example, a player becomes infected with a disease and a function is activated. The problem is I don’t know how to stop this function.
function module.Distrese(name)
if module[name] then
clone.Name = module[name].Name
clone.Image = module[name].Image
clone.Parent = Player.PlayerGui.Diseases.DiseasesFrame
Description.Text = module[name].Description
if module[name].Vibration == true then
if vibrating == nil then
vibrating = RunService.RenderStepped:Connect(function()
character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(.075math.sin(45tick()), 0,0) --anglemath.sin(velocitytick())
end)
else
vibrating:Disconnect()
vibrating = nil
end
end
if module[name].RemoveHP == true then
while true do
character.Humanoid.Health -= 2
wait(1)
end
end
end
I do not quite understand. I put a variable in a function, but I want this variable to be changeable in localscript
function module.Distrese(name)
if module[name] then
local condition = true
clone.Name = module[name].Name
clone.Image = module[name].Image
clone.Parent = Player.PlayerGui.Diseases.DiseasesFrame
Description.Text = module[name].Description
while condition do
if module[name].Vibration == true then
if vibrating == nil then
vibrating = RunService.RenderStepped:Connect(function()
character.HumanoidRootPart.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(.075math.sin(45tick()), 0,0) --anglemath.sin(velocitytick())
end)
else
vibrating:Disconnect()
vibrating = nil
end
end
task.wait()
end
end
end
never put damage on the client side!!! it will not affect player at all!
you should create module on the server and listener that will have all player’s with effect of damage in list, then module would have 2 methoods:
function module:DealDamage()
-- code to deal damage if player is in player's list
end
function module:RemovePlayerEffect(plr:String)
module.PlayerList[plr] = nil -- removes player from list, soo first function will not take him to damage list
end
Uhhh, simply, you have function that do something in while loop, and you want to stop this loop in specific case, you should create second function in your module, and this function will change condition to false, soo loop will automatically stop