I am making a visual scripting plugin and I want to make it support team create. I want to make players unable to remove script if it is being edited by other player. I made it like this:
documentScript.AncestryChanged:Connect(function(child, parent)
if child == documentScript then
if parent == nil then
RunService.Heartbeat:Wait()
child.Parent = documentScriptParent
Selection:Set({child})
error("Cannot perform operation: " .. documentScript:GetFullName() .. " is currently being edited by " .. Players.LocalPlayer.Name .. ".")
else
documentScriptParent = child.Parent
end
end
end)
But the problem is the only client who opened the script will see Cannot perform operation
error because I’m connecting the event when creating editor gui. How can I get the player who deleted the script and send him this error message?