Basically for a plugin i’m making a selection gui for when a script might be harmfull for the game the player can allow it or delete it to prevent issues with his game.
However i found myself in an issue with the plugin where only the Allow button is working.
What i attempted:
Add separate running function with task.spawn().
Code:
-- Display an alert for the user to select if keeping or removing or leaving it
local function DisplayAlert(object,reason)
ProtectionGUI.Alert.Visible = true
ProtectionGUI.Alert.Reason.Text = object.Name.." had been quarantined for the following reason: "..reason
-- Allow button
task.spawn(function()
connection1 = ProtectionGUI.Alert.Allow.MouseButton1Click:Connect(function()
if object:FindFirstChild("OriginalParent") then
if connection1 then
connection1:Disconnect()
end
if connection2 then
connection2:Disconnect()
end
object.Parent = object.OriginalParent.Value
object.Enabled = true
object:SetAttribute("AllowedScript",true)
object.OriginalParent:Destroy()
ProtectionGUI.Alert.Visible = false
else
print("Cant allow the suspected script at the time")
end
end)
end)
-- Delete Button
task.spawn(function()
connection2 = ProtectionGUI.Alert.Destroy.MouseButton1Click:Connect(function()
if connection1 then
connection1:Disconnect()
end
if connection2 then
connection2:Disconnect()
end
object:Destroy()
ProtectionGUI.Alert.Visible = false
end)
end)
task.wait(7)
ProtectionGUI.Alert.Visible = false
if connection1 then
connection1:Disconnect()
end
if connection2 then
connection2:Disconnect()
end
end
-- Display an alert to the user
if not ProtectionGUI.Alert.Visible then
DisplayAlert(object,reason)
end
-- If an alert is alredy poped up then wait
if ProtectionGUI.Alert.Visible then
repeat wait() until not ProtectionGUI.Alert.Visible
DisplayAlert(object,reason)
end