Let's say I did (extremely bleak below):
function onChatted38(message,player)
if message=="loopkill" and Admin[player.Name] then
while true do
wait()
player.Character:BreakJoints()
How could I, using a new seperate function, end the loopkill?
Any help appreciated.
I ask because in Person299's admin commands he uses something similar, but I don't understand how he did it, and I want my commands to be my own and not some copy and paste.
Stop the loop from somewhere else.
local condition=true function Loop() while condition do wait() print("loop") end end function OtherFunction() condition=false end
In the case of a loopkill program, it would actually be best to connect to CharacterAdded instead of repeatedly and redundantly killing the dead character.
Based on what you posted
local loopkill={} function onChatted38(message,player) if message=="loopkill" and Admin[player.Name] then loopkill[player.Name]=true while loopkill[player.Name]do wait() player.Character:BreakJoints() end elseif message=="unloopkill"and Admin[player.Name]then loopkill[player.Name]=nil end end
Using CharacterAdded
local loopkill={} function onChatted38(message,player) if Admin[player.Name]then if message=="loopkill"then loopkill[player.Name]=player.CharacterAdded:connect(function(character) character:BreakJoints() end) player.Character:BreakJoints() elseif message=="unloopkill"and loopkill[player.Name]then loopkill[player.Name]:disconnect() end end end