✓ Accepted answer
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
2 comments
It said something about a nil value. Could you implement it into the code given please? Sorry, this is a fairly new area of scripting for me.
updated post