I am attempting to recreate a script by CrazyMan32 called “Live Reloading” but attempting to make it a plugin
I have got it to work and execute the script live but if the user is writing a script at the time and begins to write a loop
while true do
end
apon finishing typing the loop studio instantly hangs (as it is an inf loop and the script ran it)
I have attempted to put the script execution in a separate thread but to no luck.
Also attempting to set the script timeout doesnt work (i believe it is broken?)
game:GetService("ScriptContext"):SetTimeout(5)
Also manually seting the script timeout doesnt work either is there any way to fix this
(other than not coding loops while the plugin is running)
Heres my script execution code (uses loadstring/pcalls)
local function update(scriptsource)
if scriptsource ~= nil then
local loaded, err = loadstring(scriptsource.Source)
local success = (loaded ~= nil)
if loaded then
local script_thread =coroutine.create(function()
game:GetService("ScriptContext"):SetTimeout(5)
success, err = pcall(loaded)
end)
coroutine.resume(script_thread)
end
if not success then
warn(err)
end
end
end
update(game.Workspace.Script)
GIF
Shows hanging ^